web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Get relevant position/...
Power Apps
Unanswered

Get relevant position/index of Gallery record

(1) ShareShare
ReportReport
Posted on by 70

Hello all,

 

I've got a SharePoint List with 3 columns: email (text), score (integer), week (choice column, takes values week1, week2, week3, week4).

 

Our users go through a weekly quiz and a new record is created in the SharePoint List with their weekly score.

 

I'm creating a Power App with a Leaderboard for this activity. In my app, using some formulas I've managed to display the total cumulative score for each "player" and sorted the Gallery so that top score displays first.

 

I'm now looking to add a label with the relative index/position of each record in the Gallery. For example, top cumulative score --> 1., second best score --> 2 etc.

 

Could you please help?

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @AntDim ,

    The code at the start of this blog of mine adds numbers to a gallery in the order it is sorted - the column would be RowNo.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • AntDim Profile Picture
    70 on at

    Hi Warren, thanks for your reply.

     

    So, a bit confused here. Do you say that if I copy and tweak this formula in the Text property of my label, the label will display the position of each record in the gallery in every row?

    With( { wList: Filter( SPList, StartsWith(Title,SearchBox.Text) && Status=ddStatus.Selected.Value ) }, ForAll( Sequence(CountRows(wList)), Patch( Index( wList, Value ), {RowNo: Value} ) ) )

  • Verified answer
    WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @AntDim ,

    The Items of your gallery would be exactly as you posted

    With( 
     { 
     wList: 
     Filter( 
     SPList, 
     StartsWith(
     Title,
     SearchBox.Text
     ) && 
     Status = ddStatus.Selected.Value 
     ) 
     }, 
     ForAll( 
     Sequence(
     CountRows(wList)
     ), 
     Patch( 
     Index( 
     wList, 
     Value 
     ), 
     {RowNo: Value}
     ) 
     ) 
    )

    and RowNo would be your numbered column.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

     

  • AntDim Profile Picture
    70 on at

    awesome, thank you very much!! this is working!!!

     

    I've been researching all day yesterday and trying different approaches, even asking ChatGPT for help with it but your way is the first one that gives me exactly the result I was after! I will definitely bookmark your blog above for any future reference 🙂 Thank you so much again @WarrenBelz 

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Thanks @AntDim ,

    ChatGPT has a long way to go with Power Apps code and more often serves to confuse. 

  • FemaleMarvel365 Profile Picture
    57 on at

    I'm confused does that go in the label box or does it go in the items? 

  • AntDim Profile Picture
    70 on at

    hello, I used the formula that Warren suggested in the Items property of my gallery and used RowNo for the text label of my numbered column 😊

  • DCHammer Profile Picture
    716 Moderator on at

    Took me a minute to stuff my somewhat complicated Filter statement into what he provided but that solved it perfectly.

    My use case was hiding the separator at the bottom of the gallery item when it's the last item in the gallery.

     

    The above created the RowNo value which I then used on the Visible property of the rectangle. And the upside is that every row in the gallery has a number so you can do all kinds of lovely things.

     

    Thanks again Warren. 

    Here is the Visible property for reference:

     

     

    If(ThisItem.RowNo = galItems.AllItemsCount, false, true)

     

     

     

    Since I was only after the last row, AllItemsCount was the easiest way.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard