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 / How to calculate rank ...
Power Apps
Answered

How to calculate rank in a collection

(0) ShareShare
ReportReport
Posted on by 88

If I have a collection of Activites like this:

 

{Name: User A, Count: 100}

{Name: User B, Count: 100}

{Name: User C, Count: 75}

{Name: User D, Count: 50}

 

How could I calculate what rank each user is based on the Count field? I can Sort(Activities, Count, Descending), but that would put User A above User B even though they both have the same Count. I'm looking for an output like this. 

 

RankUserCount
1User A100
1User B100
3User C75
4User D50

    

Thanks!

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

    Hi @kubalaml ,

    Try

    SortByColumns(
     Activities,
     "Count", 
     Descending,
     "User",
     Ascending
    )

     

    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.

  • kubalaml Profile Picture
    88 on at

    Well I also need the Rank field. I think I would need to do a AddColumns but not sure on what calculation I would use to display the rank of each item.

  • WarrenBelz Profile Picture
    155,775 Most Valuable Professional on at

    @kubalaml ,

    The Count sort will automatically sort in Rank order I thought. You can then simply display Rank.

     

    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.

  • kubalaml Profile Picture
    88 on at

    Well the Rank column doesn't exist. I'm trying to calculate that based on their place in the sort order. 

  • Verified answer
    WarrenBelz Profile Picture
    155,775 Most Valuable Professional on at

    @kubalaml ,

    This will add it

    With(
     {
     wCount: 
     SortByColumns(
     Activities,
     "Count", 
     Descending,
     "User",
     Ascending
     )
     },
     ForAll(
     Sequence(CountRows(wCount)),
     Patch(
     Last(
     FirstN(
     wCount,
     Value
     )
     ),
     {Rank: Value}
     )
     )
    )

     

    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.

  • WarrenBelz Profile Picture
    155,775 Most Valuable Professional on at

    Hi @kubalaml ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    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.

  • kubalaml Profile Picture
    88 on at

    Hey @WarrenBelz sorry I've been crazy busy lately. I finally got to try out that formula last night. That is an amazing formula BTW. That's super creative using Sequence like that! I don't think it's 100% the solution because, using my example above, User A would be Rank 1 and User B would be Rank 2, but I need User A and User B to both be Rank 1 because they both have the same Count. 

     

    With that being said though, this is exactly what I needed to get started. I think I can get what I need by comparing the previous count in a loop or something. 

     

    Thanks!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard