Forum Discussion
RANKX
- Anonymous4 years ago
Hi,
Please refer the following formula.
rank1 = var _tab=SUMMARIZE('Table','Table'[total scare]) Return RANKX(_tab,[total scare],,DESC,Dense)final = var _count1=CALCULATE(DISTINCTCOUNT('Table'[name id]),FILTER('Table','Table'[rank1]<EARLIER('Table'[rank1]))) var _count2=CALCULATE(DISTINCTCOUNT('Table'[rank1]),FILTER('Table','Table'[rank1]<EARLIER('Table'[rank1]))) Return 'Table'[rank1]+_count1-_count2If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards
Community Support Team _ Polly
Hi AmudhaKumaran ,
Create a measure to reference the value of total score.
total = SELECTEDVALUE('Table'[total scare])
Then create a measure to sort.
measure = RANKX(ALL('Table'),[total],,DESC,Dense)
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards
Community Support Team _ Polly
Hi Anonymous ,
Thanks for your response. For the given dataset, I agree that the logic is working as expected.
But I'm looking for a normal RANK not DENSE RANK. When I tried that measure for the actual data, Rank is based on only TOTAL score not based on ID or Name. I mean, if there are 100 unique IDs, I'm expecting 100 ranks based on IDs. But with "SELECTEDVALUE" logic, rank will be based on only Total. Tried the same measure for normal RANK instead of DENSE. This is again pointing to my initial issue.
If I try Dense, then I will get ranks 1, 2 & 3. But actual results for this dataset should be, Anu - 1, John -1, Lisa -3, Sana - 3, Ann - 5. I'm still not getting this result.
Any help would be appreciated!
- Anonymous4 years agoNot applicable
Hi,
Please refer the following formula.
rank1 = var _tab=SUMMARIZE('Table','Table'[total scare]) Return RANKX(_tab,[total scare],,DESC,Dense)final = var _count1=CALCULATE(DISTINCTCOUNT('Table'[name id]),FILTER('Table','Table'[rank1]<EARLIER('Table'[rank1]))) var _count2=CALCULATE(DISTINCTCOUNT('Table'[rank1]),FILTER('Table','Table'[rank1]<EARLIER('Table'[rank1]))) Return 'Table'[rank1]+_count1-_count2If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards
Community Support Team _ Polly
- AmudhaKumaran4 years agoHelper I
Hi Anonymous
Thank you so much for your response. That really solved my issue. Rank is now working as expected.