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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

RANKX for a filtered subset

HI guys

 

Help needed! It is a very simple task that i need to achieve but my formula does not work, for unknown reasons.

 

I have a number of locations and need to filter for the top 10 locations with the most injuries but only for locations with more than a certain amount of actual worked hours (e.g. 30'000).

 

My approach is to first filter the LOCATION Dim Table with FILTER() and then do the RANKX by Injury. 

Here's my Formula so far:

Rank = 

RANKX(
    FILTER(ALL(DM_VW_LOCATION);[Actual Worked Hours]>=30000);
    CALCULATE([Total Injuries Rate];ALLEXCEPT(DM_VW_LOCATION;DM_VW_LOCATION[SiteCode]));;DESC;Dense)

 

Unfortunately the Measure still ranks locations below the 30'000 worked hours and provides very strange results:

airfreighter_0-1597647610801.png

There's no filter on that Matrix visualization yet, but my goal is to filter for Rank<=10 so that it only shows the top 10.

Any help? 

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , for Rank refer these

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures // check category and sub category rank here
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

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
Anonymous
Not applicable

Hi @amitchandak 
Thanks for the link. I've gone through it but still don't know where things are going south. The filtering for the subset of locations does not seem to work.

Anonymous
Not applicable

did you get the solution?

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.