Forum Discussion

bbachtell's avatar
bbachtell
New Member
2 years ago
Solved

DAX Rank or Rankx

Hi all,

 

I am trying to derive the ranking of each row relative to the rows for all records in a particular year. I have tried RANK, RANKX, FILTER in various configurations, CALCULATE in various configurations and I either get 1 for all records or the rank relative to all records in the datset rather than for all records in a year. 


Here is a sample of the data in the dataset and the ranking how I would like to be able to get them to work...

 

Any hints to get this done wil be appreciated.

 

Bruce

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi bbachtell 

    You can create three meaures

    Orders Rank = RANKX(FILTER(ALLSELECTED('Table'),[Year] in VALUES('Table'[Year])),CALCULATE(SUM('Table'[Orders Receive])),,DESC)
    Processed Rank = RANKX(FILTER(ALLSELECTED('Table'),[Year] in VALUES('Table'[Year])),CALCULATE(SUM('Table'[Orders Processed])),,DESC)
    Returns Rank = RANKX(FILTER(ALLSELECTED('Table'),[Year] in VALUES('Table'[Year])),CALCULATE(SUM('Table'[Returns])),,DESC)

    Output

    Best Regards!

    Yolo Zhu

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

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bbachtell 

    You can create three meaures

    Orders Rank = RANKX(FILTER(ALLSELECTED('Table'),[Year] in VALUES('Table'[Year])),CALCULATE(SUM('Table'[Orders Receive])),,DESC)
    Processed Rank = RANKX(FILTER(ALLSELECTED('Table'),[Year] in VALUES('Table'[Year])),CALCULATE(SUM('Table'[Orders Processed])),,DESC)
    Returns Rank = RANKX(FILTER(ALLSELECTED('Table'),[Year] in VALUES('Table'[Year])),CALCULATE(SUM('Table'[Returns])),,DESC)

    Output

    Best Regards!

    Yolo Zhu

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

     

  • Yolo Zhu,

     

    This nailed it for me. I was not even close. Thank you very much!

     

    Bruce