This article describes how to add sequential row numbers to a Power Apps collection.
Use the following formula to add sequential row numbers to any collection.
ForAll (
colCollectionToBeNumbered,
Collect(
colTemp,
Last(
FirstN(
AddColumns(
DropColumns(
colCollectionToBeNumbered,
"RowNumber"
),
"RowNumber",
CountRows(colTemp) + 1
),
CountRows(colTemp) + 1
)
)
)
);
ClearCollect(colCollectionToBeNumbered,colTemp);
Clear(colTemp);
Alternative method without using Add and Drop Columns which is a bit cleaner:
With(
{
records:colCollectionToBeNumbered
},
ForAll(
Sequence(CountRows(records)),
Patch(
Last(
FirstN(records,Value)),
{rowNumber: Value}
)
)
)