Forum Discussion
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
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:
My current code for the Rank is:
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.
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/367415
1 Reply
- amitchandak
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/367415