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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
JFG123
Frequent Visitor

Dynamic ranking of data based on filter selections with groupings

I am attempting to create a ranking table whereby a user uses drop down boxes for select items, this then filters down a table and subsequently measures calculate rankings based on this filtered down data.

 

I have tried numerous approaches including:

https://community.powerbi.com/t5/Desktop/RANKX-with-groups/m-p/306074

https://www.youtube.com/watch?v=pW76t-pdUPE

and some combination thereof and have not been able to come up with a solution.

 

The rankings must be calculated by a measure as it is not possible to use calculated columns (I believe) due to the dynamic nature of the filtered down table.

 

Further, it should be noted that the table I am doing this for is already aggregated with a measure used for the ranking value.

 

The below image depicts the situation, the first portion shows the layout with ALL data included. The overall rank is the 'Max Speed Achieved' column order from highest to smallest, whereas the Rank By Car Type is the max speed achieved by each of the Cars. Further you will see that we have 3 select boxs that can be used to filter down the table.

 

In the second portion of the image, the data is dynamically filtered for just John and Luke, the overall rank and rank by car type, both update to reflect ONLY the data that is included in the table (based on the filters).

 

How should each of the ranking measures be calculated?

 

JFG123_0-1638436623840.png

 

Any help is greatly appreciated!

 

1 ACCEPTED SOLUTION

The two that worked for me, using your answer as a starting point, are:

 

overall Rank = rankx(summarize(allselected(Table), Table[Name], Table[Car Type], [Color]), [MAx speed achieved], , desc,dense)

 
 
Rank by Test Type = RANKX(FILTER(SUMMARIZE(ALLSELECTED(Table),Table[Name], Table[Car Type]]), [Car Type] = max([Car Type]))),[Max Test Value],,DESC,Skip)

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@JFG123 , Try like

 

Assume you have measure [MAx speed achieved]

overall Rank = rankx(allselected(Table), [MAx speed achieved], , desc,dense)

 

or

 

overall Rank = rankx(summarize(allselected(Table), Table[Name], Table[Car Type], [Color]), [MAx speed achieved], , desc,dense)

 

Rank by Car Type =
calculate([MAx speed achieved], filter(summarize(allselected(Table), Table[Name], Table[Car Type]]), [Car Type] = max(Car Type])), MAx speed achieved])

 

 

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

The two that worked for me, using your answer as a starting point, are:

 

overall Rank = rankx(summarize(allselected(Table), Table[Name], Table[Car Type], [Color]), [MAx speed achieved], , desc,dense)

 
 
Rank by Test Type = RANKX(FILTER(SUMMARIZE(ALLSELECTED(Table),Table[Name], Table[Car Type]]), [Car Type] = max([Car Type]))),[Max Test Value],,DESC,Skip)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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