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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add Row Number to Gall...
Power Apps
Unanswered

Add Row Number to Gallery in PowerApps

(0) ShareShare
ReportReport
Posted on by 90

Hello everyone! 

 

Here is the current formula for my Gallery's Item Property:

 

FirstN(SortByColumns(AddColumns(GroupBy('SP Data Source', "Points_x0020_Given_x0020_To","ByEmployee"),"Points Given", Sum(ByEmployee,PointsGiven)),"Points Given",Descending),10)

 

It currently provides a distinct last of names and the # of points each person has accumulated.

Example:

 

SharePoint List Items:

Bob        5

Steve      5

Bob        7

Steve    10

Joe         8

 

Gallery in PowerApps:

Steve   15

Bob     12

Joe       8

 

I would like to add row numbers to the gallery after grouping the items by name.

 

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @lparkerMDVIP 

    If you want to make a new column with a row number I suggest you check out the solution provided here:

    Link to Add A Row Number webpage:
    https://matthewdevaney.com/powerapps-collections-cookbook/add-a-row-number-column-to-a-collection/


    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @lparkerMDVIP ,

    Could you please share a bit more about your scenario?

    Do you want to add a Row Number Index into your Gallery?

     

    Based on the needs that you mentioned, I have made a test on my side, please consider take a try with the following workaround:

    Set the OnStart property of the App to following:

    Clear(RecordsCollection);
    ForAll(
     AddColumns(
     GroupBy('SP Data Source', "Points_x0020_Given_x0020_To", "ByEmployee"),
     "Points Given", 
     Sum(ByEmployee, PointsGiven)
     ),
     Collect(
     RecordsCollection,
     {
     RowIndex: CountRows(RecordsCollection) + 1,
     PointsGivenTo: 'Points Given To',
     PointsGiven: 'Points Given',
     EmployeeTable: ByEmployee
     }
     )
    )

    Set the Items property of the Gallery to following:

    FirstN(
     SortByColumns(RecordsCollection, "PointsGiven", Descending),
     10
    )

    Then re-load your app (fire the OnStart property of App), check if the issue is solved.

     

    Within your Gallery, you could reference the Row Index value through the following formula:

    ThisItem.RowIndex

     

    More details about the ForAll function, please check the following article:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-forall

     

    Best regards,

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard