Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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:
  • 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)

3 Replies

  • aadatapro's avatar
    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)

  • Additionally, you can simplify your first measure to just

    Total championships = COUNT(Champions[Champion])
    Hope this helps.
  • Anonymous's avatar
    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.