Showing results for 
Search instead for 
Did you mean: 

New Function : Index - to index a table with a sequential number

It would be GREAT to have a function such as Index that would index a table and return a Table with an added column containing a sequential number based on the order of the Rows in the table.


Example:  Index(tableName, "indexColumn")   would return a table of the tableName table with an added column containing the sequential number of the row in the order of the table.


Why this Idea?  Because there are a lot of Ideas on the forum that revolve around this in some way - "collection with an index", "index for a gallery row", etc.   While it would be nice to have those individually, a quicker way to get there would be to provide an Index function that could be used for all of them.


The Function would be equivalent to the following (based on the mentioned syntax above):


        Patch(Last(FirstN(tableName, Value)), {indexColumn: Value})


Which is perfect at indexing a table...

But this would be MUCH more convenient as a Function in PowerApps.


I would not expect this to be delegable...just convenient!

Status: New
Regular Visitor

Small correction to the function in case someone tries to use it in their app:


    Patch(tableName, Last(FirstN(tableName, Value)), {indexColumn: Value})


I much prefer this formula to the one where you have to copy everything into a new collection.
One thing I found was I needed to have indexColumn already defined in my collection first (although initially it was all zeroes).

Would be great just to have an Index function though.