Skip to content

Power Apps

Rank From Highest To Lowest With Ties

Rank From Highest To Lowest With Ties Input collection: myHighScores28 Name Value Jim Anderson 100 Winnie Lee 78 Jane Nelson 100 Anders Erickson 135 Timothy ...

Matthew Devaney
Published
Reading time
1 min read

Before you start

Is this guide for you?

Best entry point
Power Apps
Time investment
1 min read

Imported reference from Matthew Devaney's blog for learning purposes. Original: https://www.matthewdevaney.com/powerapps-collections-cookbook/get-rows-with-top-values/. Author: Matthew Devaney.

Rank From Highest To Lowest With Ties Input collection: myHighScores28 Name Value Jim Anderson 100 Winnie Lee 78 Jane Nelson 100 Anders Erickson 135 Timothy Green 15 Elizabeth Martin 50 Output collection: mySolution28 Name Value Anders Erickson 135 Jim Anderson 100 Jane Nelson 100 Winnie Lee 75 Elizabeth Martin 50 Timothy Green 15 Solution code: //Create a collection

ClearCollect(myHighScores28, { Name : "Jim Anderson" , Value : 100 }, { Name : "Winnie Lee" , Value : 75 }, { Name : "Jane Nelson" , Value : 100 }, { Name : "Anders Erickson" , Value : 135 }, { Name : "Timothy Green" , Value : 15 }, { Name : "Elizabeth Martin" , Value : 50 } ); //Rank from highest to lowest code

ClearCollect( myCountedValues, Sort( AddColumns( GroupBy(myHighScores28, "Value" , "GroupedValues" ),

"CountValue" ,CountRows(GroupedValues) ), Value,Descending ) ); //Rank counter collection ClearCollect(rowCounter,{ Value : 1 });

//Rank from highest to lowest code continued

Clear(myRankedValues); ForAll( myCountedValues, Collect( myRankedValues, { RankNumber : First(rowCounter).Value, Value : myCountedValues[@Value],

CountValue : myCountedValues[@CountValue],

GroupedValues : myCountedValues[@GroupedValues] }); Patch( rowCounter, First(rowCounter), { Value : First(Sort(myRankedValues,RankNumber,Descending)).RankNumber + CountValue} ); );

ClearCollect( mySolution28, Sort( DropColumns(Ungroup(myRankedValues, "GroupedValues" ), "CountValue" ), RankNumber, Ascending ) ); Code language: JavaScript ( javascript )

Share this

Tagged

Power Apps

Have a Microsoft 365 topic idea?

Share article suggestions, community session ideas, corrections, or real-world scenarios for future nextM365 learning notes.

Suggest a topic

Keep learning Microsoft 365

Explore more practical guides for SharePoint, Power Platform, Copilot Studio, migration, automation, governance, and security.

Continue learning

Next action

What to do next

Browse all tutorials →