Loop within loop?

Is it possible to run a loop inside a loop in order to concatenate different levels of the same data structure?

*Note: After concatenation, the objects must still behave as objects, meaning that when hovered on they display the Preview modal. (In one partial solution, I achieved concatenation, but lost object status because concatenation converted it to text.)

Like this:

I’ve tried everything I can think of, but coming up short here.

1 Like

Hey @Ander, not sure if this is the solution you’re looking for since it’s not exactly an array of arrays, but it gives you the ability to hover over the different levels of the arrays using the FormulaMap() function:

The formula in “desired” is:

=FormulaMap([TS Multiselect],concatenate(CurrentValue,Lookup([Table 5],S, CurrentValue.ToText()).[SB Multiselect] ))

1 Like

Thanks @Al_Chen_Coda !! This was very helpful.

I had to fiddle a bit longer to get a solution that will work in the project’s surrounding context (not visible in the screenshots), but I think I got it. Posted below for others who might be interested.

(1) Lookup() solution: FormulaMap([TS multiselect],Concatenate(CurrentValue,Lookup([Table 5],S,CurrentValue.ToText()).[SB multiselect] ))

(2) Filter() solution: FormulaMap([TS multiselect],Concatenate(CurrentValue,": ",filter([Table 5],S=CurrentValue.ToText()).[SB multiselect]))

(3) nested FormulaMap() solution: Sequence(1,count([TS multiselect]),1).FormulaMap(Concatenate([TS multiselect].Nth(CurrentValue),": ",FormulaMap([TS multiselect].[SB multiselect].Nth(CurrentValue),Concatenate(CurrentValue,", "))))

  • Note 1: I’d be interested to learn how to remove those trailing commas.
  • Note 2: I don’t understand the formula editor error prompt in this case: “Wrong argument type”
1 Like

The trailing comma happens because you are using the Concatenate function. You could also use the Join function which joins a list of items by a provided value (see formula page here).

The formula error is a usability issue with how we treat CurrentValue. Is the formula returning your desired result?

1 Like

@Al_Chen_Coda Yeah, I’d previously tried using join(), like this:

Sequence(1,count([TS multiselect]),1).FormulaMap(Concatenate([TS multiselect].Nth(CurrentValue),": ",join(", ",[TS multiselect].[SB multiselect].Nth(CurrentValue))))

It removes the trailing commas, but kills the object status of the list items being joined, I assume because join() converts them to text.

Anyway, the trailing commas are fine for the time being. And yes, the formula is returning the desired result, so it’s good to know that formula error is just a usability issue. Thanks for this follow-up.

1 Like