Forum Discussion
Add ranking in table with DAX
Hi All,
I would like to add a rank by Amount in the following table.
I tried to add the ranking with the following codes but the ranking is not in proper order.
Previously, the ranking is worked with ALLSELECTED function, but now it shows curly line under the second column.
Hi amitchandak , your DAX works if I removed the "Case" column.
In order for me to show "Case" column, I modified my DAX as following:# Case =SWITCH(TRUE(),NOT(ISBLANK(RANKX (summarize( ALLSELECTED(FactTable),FactTable[ClaimType],FactTable[Diagnosis]), 'Measure'[Amount],,DESC,Dense))),[Case])My ranking order is perfect now.Thank you!
4 Replies
- amitchandak
Super User
PowerBIOrg , Try like
RANKX ( Summarize(ALLSELECTED('FactTable'),'FactTable'[ClaimType], 'FactTable'[Diagnosis]), [Amount],,DESC )
- PowerBIOrg
Resolver II
- PowerBIOrg
Resolver II
Hi amitchandak , your DAX works if I removed the "Case" column.
In order for me to show "Case" column, I modified my DAX as following:# Case =SWITCH(TRUE(),NOT(ISBLANK(RANKX (summarize( ALLSELECTED(FactTable),FactTable[ClaimType],FactTable[Diagnosis]), 'Measure'[Amount],,DESC,Dense))),[Case])My ranking order is perfect now.Thank you!
- Jihwan_Kim
Super User
Hi,
I am not sure how your data model looks like, but try to include all columns that are realted to ClaimType-Column and Diagnosis-Column. For instance, try to find the sorting-columns for the ClaimType and Diagnosis columns and try to includ these in the measure.