Skip to main content
Community site session details

Community site session details

Session Id : 3zaqmHDt6OWhHRH94n5yRE
Power Apps - Building Power Apps
Answered

add a rank column to a collection

Like (0) ShareShare
ReportReport
Posted on 27 Mar 2024 13:25:04 by 12

Hi,

 

have a collection called "colApplicants":

ApplicantScore
Person A

0.1

Person B0.5
Person C0.3
  

 

Now i want to add a column named "rank", so it should look like this:

ApplicantScorerank
Person A0.13
Person B0.51
Person C0.32

 

Unfortunately, I haven't been able to find a way to do this anywhere other than writing it to a SharePoint list and then applying a flow. However, I would like to implement it using only a powerapp. Does anyone have an idea how this could work?

 

Thanks in advance

  • jhjtbq4hjbt Profile Picture
    12 on 27 Mar 2024 at 14:24:17
    Re: add a rank column to a collection

    That was very helpfull. Thank you very, very, very much. everything worked. That was very helpfull

  • Verified answer
    v-mengmli-msft Profile Picture
    on 27 Mar 2024 at 13:46:10
    Re: add a rank column to a collection

    Hi @jhjtbq4hjbt ,

     

    Please try this.

    With(
     {
     COL: 
     SortByColumns(
     colApplicants,
     "Score", 
     SortOrder.Descending,
     "Applicant",
     SortOrder.Ascending
     )
     },
     ForAll(
     Sequence(CountRows(COL)),
     Patch(
     Last(
     FirstN(
     COL,
     Value
     )
     ),
     {rank: Value}
     )
     )
    )

     

    Best regards,

    Rimmon

  • Verified answer
    cdwhite Profile Picture
    1,067 Most Valuable Professional on 27 Mar 2024 at 13:45:23
    Re: add a rank column to a collection

    Hi @jhjtbq4hjbt ,

    Please see the 2nd part of my response; you'll need to create a collection using the logic provided.

    I've tested at my end and works as expected 😀
    ------------------------------------------------------------------------------------------------------------------------------
    If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.

    If my response was a good one, please give it a Thumbs Up!

    Visit my blog: https://platformsofpower.net

  • jhjtbq4hjbt Profile Picture
    12 on 27 Mar 2024 at 13:42:37
    Re: add a rank column to a collection

    @cdwhite Thanks for the reply

    i will test it

  • cdwhite Profile Picture
    1,067 Most Valuable Professional on 27 Mar 2024 at 13:40:50
    Re: add a rank column to a collection

    Hi @jhjtbq4hjbt 

    if you just want to visualise this in a gallery, you could put the below Power Fx into the Items property:

     

    ForAll(
     Sequence(CountRows(colApplicants)),
     Patch(
     Index(
     SortByColumns(
     colApplicants,
     "Score",
     SortOrder.Descending
     ),
     Value
     ),
     {RowNo: Value}
     )
    )

     

    You can then add the RowNo output to see the value:

    cdwhite_0-1711546744771.png

    If you want this stored as a collection so you can do extra things with the outputs, you can extend the code like so & add it to a behavioural property such as OnSelect of a button:

    ClearCollect(colApplicantsRanked,
    ForAll(
     Sequence(CountRows(colApplicants)),
     Patch(
     Index(
     SortByColumns(
     colApplicants,
     "Score",
     SortOrder.Descending
     ),
     Value
     ),
     {RowNo: Value}
     )
    ))

    Hopefully the above should work for you!

    ------------------------------------------------------------------------------------------------------------------------------
    If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.

    If my response was a good one, please give it a Thumbs Up!

    Visit my blog: https://platformsofpower.net

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete