Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
AuroraNI
Helper III
Helper III

RANKX in a dynamic table

Hi all,

I have had a look on some of the other posts around this and also on youtube but can't get my RankX to do what I need it to do so would be grateful for some assistance.

 

I have a simple table where I want to rank runners based on time and be able to use a slicer to select different events.  I want the rank to rank the runners 1-8 for the race selected in the slicer as shown below

 

AuroraNI_0-1603446037461.png

However when I select another event it ranks it based on the whole table rather than the selected one as I want to still rank it 1-8 for this event:

AuroraNI_1-1603446115905.png

My current code for the Rank is:

AuroraNI_2-1603446176947.png

I have looked in the forums which suggest using 'AllSelected' and/or 'Filter' but I cannot get it to work and I know it is a simple solution.

 

Thanks for any assistance.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@AuroraNI , What you are creating a column Rank. For it to be dynamic you need measure rank. measure rank requires a rank.

So might have to convert this time in duration in min or sec and use it. or use min/max and use it

 

rankx(allselected(Table), calculate(Min[time])) ,,asc)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@AuroraNI , What you are creating a column Rank. For it to be dynamic you need measure rank. measure rank requires a rank.

So might have to convert this time in duration in min or sec and use it. or use min/max and use it

 

rankx(allselected(Table), calculate(Min[time])) ,,asc)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors