cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lparkerMDVIP
Helper III
Helper III

Add Row Number to Gallery in PowerApps

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.

 

2 REPLIES 2
mdevaney
Super User III
Super User III

@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
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (84,854)