
Summary
The Power Apps INDEX function returns a row from a table by specifying the row number. For example, we could get the 2nd row of a table by supplying the table name and the number 2.
Syntax
Index(Table, Index) |
Arguments
Name | Required? | Description |
Table | Yes | A table of values. |
Index | Yes | The row number in the table to be returned. Top row is 1, the next row is 2, then 3, etc. |
Examples
The Customers table contains the following names, addresses and cities.
Full Name | Address | City |
Matthew Devaney | 115 Main Street | Winnipeg |
Sarah Green | 45 Henderson Highway | Brandon |
Kelly Smith | 34 Portage Avenue | Steinbach |
David Johnson | 10 Commerce Drive | Kenora |
To get the 2nd row of the table we can write an INDEX function like this:
Index(Customers, 2)
The result is:
Full Name | Address | City |
Sarah Green | 45 Henderson Highway | Brandon |
We can also use the Power Apps INDEX function to get a value from a specific row of the table. To get the Full Name from the 2nd row we can write this code.
Index(Customers, 2).'Full Name'
The result is:
Sarah Green
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps articles sent to your inbox each week for FREE
Thanks for your article. When I do the same, it won’t work.
I try to do it from a datatable, created from a collection with this formula : Index(DataTable1;1).relevé
If i use a galery in the same context, with this formula : Index(Gallery5.AllItems;1).Relevé = it works ?
Why such an issue with a table versus a galery ?
Thanks in advance
Sevellec,
Power Apps has 2 different syntaxs. The English syntax uses a comma [,] to separate arguments whereas the French syntax uses [;]. Here is a link to the documentation for syntax differences: https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/global-apps#formula-separators-and-chaining-operator
I do not like that Power Apps works in this way. Having 1 consistent syntax would benefit the platform greatly.
Hey Matthew,
Firstly I love your site, you have shared so many useful guides that have saved me an enormous amount of time, so thank you very much!
Secondly, I assume that we couldn’t use this to do a clearcollect on a dataset of more than 2000 records?
Thanks in advance
Simon,
I’m afraid not. But I do have this helpful article to help you get past 2,000 records.
https://www.matthewdevaney.com/create-power-apps-collections-over-2000-rows-with-these-4-tricks/
Hi Matthew,
First thank you for all of your help. It has been a life saver as I learn powerapps.
I have a working gallery that collects input data. I want to use the value in the second location of the gallery for a comparison function. Index will return the value I need but once we add more data to the gallery it seems to follow the initial index. Is there a way to only pull the current data in the second position.
Thanks Again!
Matt,
Sorry, I don’t understand the question. It might be helpful to show what’s in your gallery and then tell me what needs to be extracted.