How to add multiple rows to a table with FormulaMap, with a value that increases by +1 in each row?

I’ve been using Formula Map to add multiple rows to a table, with the Column 1 names drawn from a Multiselect control.

The issue is that I want the “Order #” for each of those rows to incrementally increase… I currently have the following formula, which sets the “Order #” of the row as the MAX value +1… but formula map is not re-calculating the max value as it progresses from row to row. Each row ends up with the same “Order #.”

FormulaMap([Multiselect Control],AddRow([Order Table],[Order Table].[Order #],max([Order #])+1,[Col1],CurrentValue))

Any ideas?

One way to do it strictly as you put it is:

Sequence(1, [Multiselect Control].Count())).FormulaMap(
  AddRow([Order Table],
    [Order Table].[Order #],max([Order #])+CurrentValue,
    [Col1],[Multiselect Control].Nth(CurrentValue)

See this:

But I’d probably use a column formula to guarantee unique order numbers: [Order Table].[Order #] = thisRow.RowId()

1 Like

Actually, using the Sequence formula would be better than using RowID, since the RowID formula is unreliable when adding multiple rows.

Just putting this here to save a lot of debugging and frustration.