cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
3zman87
Frequent Visitor

Powerapps Ranking field in gallery

Hi,

Can anyone help with a formula to automatically enter a participants position in a ranking table. 

I have everything figured out other than this. (don't mind the solution being for SharePoint or PowerApps).

A FireStation will submit there entry for money raised and this will total in a league table so the can compete against each other.

 

1 -FireStation A  £300

2- FireStation B £250

3- FireStation C £100

 

I would like it to change the Rank ID position if FireStation C submits an entry of £300 so they would change to rank 1.

 

Any assistance would be great. Thanks.

Been on the forums before but never posted.

4 REPLIES 4
dyee
Resolver II
Resolver II

I don't have a great solution for this.  Here is what I'd do.  

 

1 - Summarize the data using groupby

Groupby --> GroupBy(DataSource, "Station", "StationSummaryName")

 

2) Create a gallery and in the gallery make a label summing the total sum(ThisItem.StationSummaryName,MoneyRaised).  

 

3) Create an IF statement to rank it.  It will be something like IF( Sum(Filter(DataSource, Firestation = Firestation A, MoneyRaised) > Sum(Filter(DataSource, Firestation = Firestation B, MoneyRaised), 1, etc..

3zman87
Frequent Visitor

Thanks for your response.

Though on this occasion a formula like that wouldn't work as there are over 100 Fire Stations and other departments involved.

JacquesOlivier
Helper I
Helper I

You can determine the rank with the use of a timer to iterate through the sorted dataset.
The solution uses a Button and a Timer.
Button.OnSelect
Clear(colrank); //colRank are the items to display in the gallery 
ClearCollect(colData, {Name:"Fire A", Raised:150}, {Name:"Fire B", Raised:250}, {Name:"Fire C", Raised:50}, {Name:"Fire D", Raised:350}); // this is my dummy data replace the colData below with your data 
ClearCollect(sortedData, Sort(colData, Raised, SortOrder.Descending)); //sorting the data on the amount raised
UpdateContext({rows:CountRows(sortedData)}); // getting the number of rows 
UpdateContext({count:1}); //setting the first rank
UpdateContext({calcRank:true}); //start the timer

Timer

Start = calcRank
Repeat = true

 

OnTimerStart
UpdateContext({r:Last(FirstN(sortedData, count))}); //get the current record (read-up on Last, FirstN functions to get a record on an index ) 
Collect(colrank, {rank:count, title:r.Name, raised:r.Raised}); //insert the record in the collection to display the rankings

 

OnTimerEnd
UpdateContext({count: count + 1}); //increment the count / rank
UpdateContext({calcRank: rows > count}); //check if your reached the last record and stop the timer.

JacquesOlivier_0-1622812755120.png

 

zmorek
Super User
Super User

Could also just sort the gallery by descending on the amount column, and have labels outside the gallery (thus they wouldn't move when the gallery sort changes) that line up with the rows in the gallery to indicate 1st, 2nd, etc.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,732)