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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
scabral
Helper IV
Helper IV

Create dynamic Ranking measure

Hi,

 

have the following table:

 

ClassificationDivision OperationsValueYear
HealthcareEasternBoston1,000,0002021
HelathcareWesternLos Angeles500,0002021
HealthcareWesternSan Francisco250,0002021
ManufacturingSouthernTexas100,0002020
ManufacturingSouthernFlorida5,400,0002020

 

So each field (except Value) will be a slicer.  The ranking will need to be done dynamically depending on what slicers are selected.  So if Healthcare is selected, the ranking will take into account the 3 rows for healthcare and rank by value descending.  If Healthcare and Los Angeles are selected, then the ranking will be done with just that row.  If no slicers selected, than rank entire table.

 

not sure how to use Rankx function to get this done.  So far my results don't bring back what i am expecting.

 

Scott

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @scabral ,

 

The formula should be:

Measure = Rankx(ALLSELECTED('Table'),CALCULATE(Sum('Table'[Value])),,desc,dense)
Otherwise it will always return 1.
 
Best Regards,
Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @scabral ,

 

The formula should be:

Measure = Rankx(ALLSELECTED('Table'),CALCULATE(Sum('Table'[Value])),,desc,dense)
Otherwise it will always return 1.
 
Best Regards,
Jay
amitchandak
Super User
Super User

@scabral , Try like

 

Rankx(allselected(Table[Classification]) , calculate(Sum(Table[Value])) , ,desc, dense)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Measure Rank: https://www.youtube.com/watch?v=DZb_6j6WuZ0&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=40

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.