How To Use The Power Apps INDEX Function



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
NameRequired?Description
TableYesA table of values.
IndexYesThe 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 NameAddressCity
Matthew Devaney115 Main Street Winnipeg
Sarah Green45 Henderson HighwayBrandon
Kelly Smith34 Portage AvenueSteinbach
David Johnson10 Commerce DriveKenora




To get the 2nd row of the table we can write an INDEX function like this:

Index(Customers, 2)



The result is:

Full NameAddressCity
Sarah Green45 Henderson HighwayBrandon




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


Subscribe
Notify of
guest

10 Comments
Oldest
Newest
Inline Feedbacks
View all comments
sevellec
sevellec
1 year ago

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

Simon
Simon
1 year ago

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

Matt
Matt
10 months ago

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!

Dave Taylor
7 months ago

Hi Matthew,

I think I am having a similar problem to Matt above, that I am getting an error stating that Index Function must be between 1 and 2, the lower and upper bounds of the table, but my data is almost 20 bits of information.

The data is in a collection, that is built in segments as it sits behind a Wizard, the first section is name and org type questions, then there area some other ‘stored’ questions that I inject into the collection from other places.

The issue only happens when I call the code on the same screen as the wizards controls, so my assumption is that the error is called when I clear the collection to rebuild it, so I can work around the issue, but I just want to understand why it happened as its eaten my afternoon.

Many Thanks

Dave

PS Love the Blogg and loved you and Shane getting together. All my Xmases and Birthdays at once!

PPS An image of my cat..assuming you do like cats

Untitled.png
Truc
Truc
1 month ago
Reply to  Dave Taylor

Hi Taylor,
Can you share you solution in more details?
Thank you very much

Kenny
Kenny
8 months ago

Hi Mathew, thanks for this article.
By any chance, is there an out of the box method to achieve the reverse of this. I want to get the index/row no of a record. i have the record, but i don’t know what row it is.