Forum Discussion
jmandhare
4 years agoFrequent Visitor
Dynamic Ranking - Contract Type, Contract Name, and Total Amount - Rankx
Hello All, I am currently facing an issue with creating a dynamic rank. I am still at the beginning phase of DAX so not able to crack how rankx works. Problem: I have two tables view_contracts...
- 4 years ago
I guess no one able to find the solution for this yet. I was able to crack it myself. Just posting it over here if anyone wants to know the solution for it.
For this, you need to create two measures in the view_contracts table:
ISCategory (Require for Rank by Contract Type) = COUNTROWS('view_contracts') = CALCULATE(COUNTROWS('view_contracts'),ALL('view_contracts'), VALUES('view_contracts'[contract_type]))Rankx by contract_type = IF( [ISCategory (Require for Rank by Contract Type)], RANKX( ALLSELECTED(view_contracts[contract_type]),CALCULATE(SUM(view_payments[total_amount]))), RANKX(ALLSELECTED(view_contracts[contract_name]),CALCULATE(SUM(view_payments[total_amount])),,DESC,Skip))I have to redact some information. I hope it helps someone who is looking for it.
Regards,
JM
jmandhare
4 years agoFrequent Visitor
I guess no one able to find the solution for this yet. I was able to crack it myself. Just posting it over here if anyone wants to know the solution for it.
For this, you need to create two measures in the view_contracts table:
ISCategory (Require for Rank by Contract Type) = COUNTROWS('view_contracts') = CALCULATE(COUNTROWS('view_contracts'),ALL('view_contracts'), VALUES('view_contracts'[contract_type]))
Rankx by contract_type = IF( [ISCategory (Require for Rank by Contract Type)], RANKX( ALLSELECTED(view_contracts[contract_type]),CALCULATE(SUM(view_payments[total_amount]))), RANKX(ALLSELECTED(view_contracts[contract_name]),CALCULATE(SUM(view_payments[total_amount])),,DESC,Skip))
I have to redact some information. I hope it helps someone who is looking for it.
Regards,
JM