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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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

5 REPLIES 5
Riya_Agg
New Member

i ahve this rank measure

Dynamic MIDP Rank =
RANKX(
    ALLSELECTED('Product Movement with AMI data'[SWTX_BUYER_NAME]),
    CALCULATE(MAX('Product Movement with AMI data'[SWTX_BUYER_NAME]),ALL('Product Movement with AMI data'[INVOICE_NUMBER],'Product Movement with AMI data'[TRANSACTION_ID],'Product Movement with AMI data'[STD_NDC],'Product Movement with AMI data'[SHIPMENT_DATE],'Product Movement with AMI data'[SWTX_SELLER_NAME],'Product Movement with AMI data'[Summarized AMI Data.SWTX_BUYER_NAME],'Product Movement with AMI data'[NPI],'Product Movement with AMI data'[Territory],'Product Movement with AMI data'[PDRP])),
    ,
    ASC,
    DENSE
)
and this pdrp filter measure which i keep in filter pane 
PDRP Filter = IF([Role] = "Regional Business Director" && MAX('Product Movement with AMI data'[PDRP]) = "Y",0,1)
Now i want when i apply filter it will not affect ranking please give the approach
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

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

i ahve this rank measure

Dynamic MIDP Rank =
RANKX(
    ALLSELECTED('Product Movement with AMI data'[SWTX_BUYER_NAME]),
    CALCULATE(MAX('Product Movement with AMI data'[SWTX_BUYER_NAME]),ALL('Product Movement with AMI data'[INVOICE_NUMBER],'Product Movement with AMI data'[TRANSACTION_ID],'Product Movement with AMI data'[STD_NDC],'Product Movement with AMI data'[SHIPMENT_DATE],'Product Movement with AMI data'[SWTX_SELLER_NAME],'Product Movement with AMI data'[Summarized AMI Data.SWTX_BUYER_NAME],'Product Movement with AMI data'[NPI],'Product Movement with AMI data'[Territory],'Product Movement with AMI data'[PDRP])),
    ,
    ASC,
    DENSE
)
and this pdrp filter measure which i keep in filter pane 
PDRP Filter = IF([Role] = "Regional Business Director" && MAX('Product Movement with AMI data'[PDRP]) = "Y",0,1)
Now i want when i apply filter it will not affect ranking please give the approach

Hello, If I have some slicers which are not present in the table visual, How should I write it? For eg. a slicer for country shoud affect the visual and change rank accordingly, but is not present as a column in the table visual. Thanks.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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