Forum Discussion

corange's avatar
corange
Post Patron
5 years ago

RANKX breaks when adding another measure / fields

Hi everyone, 

 

I am trying to rank clients based on profit. 

 

I have used this formula: 

 

RANK = RANKX(ALL('2 - JobsDetails'[CLIENT_CODE]),CALCULATE([Profit],ALLEXCEPT('2 - JobsDetails','2 - JobsDetails'[CLIENT_CODE])))
 
and also tried this one: 
 
RANK= RANKX(ALLSELECTED('2 -JobsDetails'[CLIENT_CODE]),CALCULATE(SUM('2 - JobsDetails'[TOTAL_CHARGE])-SUM('2 - JobsDetails'[TOTAL_PAY])),,DESC,SKIP)
 
However when I tried adding other measure / field in my visual, the rank breaks. I have double 2s ranking or 17s... 
 
Could someone let me know what I am missing in my formula or propose one that will only rank the profit while letting me add other measures to the visual so I can present my data. 
 
Thanks in advance. 
 

1 Reply

  • corange try this measure:

     

    RANK = 
    RANKX(
    ALLEXCEPT (  '2 - JobsDetails', '2 - JobsDetails'[CLIENT_CODE] ),
    [Profit], , 
    DESC
    )

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.