web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Answered

How to rank rows?

(1) ShareShare
ReportReport
Posted on by 4
But How would you write an expression that ranks rows based on their DateTime column in a Power Apps canvas app?

I'm looking to display a rank for each row for a group of bike racers.
 
The 'Finishing Position' is not in the Dataverse table so it will need to be added as a collection variable.
 
Any suggestions on how to approach this?
 
I tried:
CountRows(
Filter(
colSortedResults,
Not(IsBlank('Finish Time')) &&
'Finish Time' < ThisRecord.'Finish Time'
)
) + 1
 
But this returned all riders with a '1' as their 'Finishing Position'.
 
I also tried:
If(
IsBlank(nt_finish_time),
Blank(),
CountRows(
Filter(
colSortedResults,
Not(IsBlank(nt_finish_time)) &&
nt_finish_time <= ThisRecord.nt_finish_time
)
)
)
 
But this returned all riders with a '3' as their Finishing Position'.
 
What am I missing?
Categories:
I have the same question (0)
  • Verified answer
    Nandit Profile Picture
    1,568 Moderator on at
     
    Can't we just sort the records by Finish Time and add an index to it, starting from 1 - count of records?
    Here's a code that I have added to a button to first sort the data in Ascending, save it in a collection, and then add a Rank to it - 
     
    ClearCollect(
        colRanks,
        AddColumns(
            SortByColumns(
                Results,
                'Finish Time',
                SortOrder.Ascending
            ),
            Rank,
            0
        )
    );
    ClearCollect(
        colRanks,
        ForAll(
            Sequence(CountRows(colRanks)),
            Patch(
                Last(
                    FirstN(
                        colRanks,
                        Value
                    )
                ),
                {Rank: Value}
            )
        )
    )
    Here's a screenshot:
     
    Hope this helps. 
     
    Kind regards,
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard