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

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?

Any help is greatly appreciated!

1 ACCEPTED SOLUTION
Frequent Visitor

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)
2 REPLIES 2
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])

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!
Frequent Visitor

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)

Announcements