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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

Help: RANKX with filtering from another table

Hi there,

 

My first post so apologies if this has been answered elsewhere.

 

I'm looking to add a ranking to a column and dynamically change the results and subsequently the rank when filtered by another field. The current syntax I'm using is:

 

Rank =
RANKX ( ALL ( Table[Column_Name] ), CALCULATE ( SUM ( Table[Column_Name] ) ) )
 
This works perfectly fine in isolation and gives me the correct ranking. The issue is, when I create a filter using a field from another table, the field that I'm ranking remains the same, when I would expect it first to be filtered, and then the ranking to be applied.
 
As an example, let's say we have 100 companies and all are ranked 1-100, the current ranking syntax works fine. I then add a filter for company industry (which sits in another table), I would then expect when I select an industry for the initial results to change, say to 50 companies and then the ranking to display the 1-50 for the industry selected.
 
Hope that makes sense. Driving me mad so any help would be great, thank you.
 
Lloyd
1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1600050174190.png

v-lionel-msft_0-1600233745581.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1600050174190.png

v-lionel-msft_0-1600233745581.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Anonymous See if this helps:

https://community.powerbi.com/t5/Quick-Measures-Gallery/To-Bleep-with-RANKX/m-p/1042520#M452

 

Otherwise maybe post sample data and expected output.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous ,

 

see if this changes can help

RANKX ( ALLSELECTED  ( Table[Column_Name] ), CALCULATE ( SUM ( Table[Column_Name] ) ) )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors