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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Rankx not working correctly

Hello everyone, 

 

I have a simple RankX function, but it's not working as expected. I want to rank F1 drivers with the most championship titles. 

 

The formula for the titles is: 

Total championships =
CALCULATE(COUNT(Champions[Champion]), ALL('Date'), 'Date'[Date] <= MAX('Date'[Date]))
 
The Rank formula is:
Rank champions =
RANKX(ALL(Champions),[Total championships],,DESC, Dense)
 
The result is this:
Rank champions.jpg
1 ACCEPTED SOLUTION
aadatapro
Frequent Visitor

If you restrict your first parameter of the Rankx function to the column or columns you want to rank by, this should solve your issue e.g.
RANKX(ALL(Champions[Champion]),[Total championships],,DESCDense)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks! That worked. 

@Ashish_Mathur , thanks for your suggestion. I have an animated dashboard, so that's why I've added the filter context. 

Ashish_Mathur
Super User
Super User

Additionally, you can simplify your first measure to just

Total championships = COUNT(Champions[Champion])
Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
aadatapro
Frequent Visitor

If you restrict your first parameter of the Rankx function to the column or columns you want to rank by, this should solve your issue e.g.
RANKX(ALL(Champions[Champion]),[Total championships],,DESCDense)

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.