cancel
Showing results for 
Search instead for 
Did you mean: 
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

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

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
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!