Forum Discussion
Rank Measure
I have this measure
26 Replies
- hnguy71Super User
Hi bdehning ,
there should be optional parameters after your count measure. Something like this:
IF ( ISINSCOPE( 'InjuryCause'[Cause Grouping]), RANKX ( CALCULATETABLE ( VALUES ( 'InjuryCause'[Cause Grouping]), ALLSELECTED ( 'InjuryCause'[Cause Grouping] ) ), [Count of Total Gross Incurred], DESC, DENSE ) )- bdehningPost Prodigy
I get
"Unexpected value for ORDER argument in RANKX function. Use 0/FALSE/DESC for descending order or 1/TRUE/ASC for ascending order." using that.
- hnguy71Super User
bdehning ,
can you try this?
IF ( ISINSCOPE( 'InjuryCause'[Cause Grouping]), RANKX ( CALCULATETABLE ( VALUES ( 'InjuryCause'[Cause Grouping]), ALLSELECTED ( 'InjuryCause'[Cause Grouping] ) ), [Count of Total Gross Incurred], , DESC, DENSE ) )maybe I was missing an extra comma, added it after your count.
- CNENFRNLCommunity Champion
= IF( ISINSCOPE( 'InjuryCause'[Cause Grouping] ), RANKX( CALCULATETABLE( VALUES( 'InjuryCause'[Cause Grouping] ), ALLSELECTED( 'InjuryCause'[Cause Grouping] ) ), [Count of Total Gross Incurred], , DESC ) ) - bdehningPost Prodigy
Ok it took that but I need to add DENSE as I get muliple same ranking numbers?
- bdehningPost Prodigy
Or add someting to eliminate this
1
2
3
4
5
5
5
5
5
- bdehningPost Prodigy
I want
1
2
3
4
5
6
7
8
9
10
11
- bdehningPost ProdigyThe following although not showing error still produces thisIF (ISINSCOPE( 'InjuryCause'[Cause Grouping]),RANKX (CALCULATETABLE (VALUES ( 'InjuryCause'[Cause Grouping]),ALLSELECTED ( 'InjuryCause'[Cause Grouping] )),[Count of Total Gross Incurred],,DESC,DENSE)
)123455555- hnguy71Super User
bdehning ,
In this case, you need a sort of ... tiebreaker. Try something like this...
VAR _TieBreaker = IF( ISINSCOPE('InjuryCause'[Cause Grouping]), VAR _cRecord = MAX('InjuryCause'[Cause Grouping]) VAR _tmpRank = COUNTROWS( FILTER(ALL('InjuryCause'), 'InjuryCause'[Cause Grouping] >= _cRecord )) RETURN _tmpRank ) RETURN IF( ISINSCOPE( 'InjuryCause'[Cause Grouping]), RANKX ( CALCULATETABLE ( VALUES ( 'InjuryCause'[Cause Grouping]), ALLSELECTED ( 'InjuryCause'[Cause Grouping] ) ), [Count of Total Gross Incurred] + DIVIDE(_TieBreaker, 100), , DESC, DENSE ) )- bdehningPost Prodigy
Ok excuse my novice to this, what is cRecord and why the divide?
All I want to do it use the Count of Total Gross Incurred to establish the rank and then use Sum of Total Gross Incurred for each Cause Group to break the tie.
- Ashish_MathurSuper User
Hi,
Share the download link of your PBI file.
- bdehningPost Prodigy
I wish I could, but data needs to be protected.
- Ashish_MathurSuper User
Hi,
Anonymise some data clearly showing the issue that you are facing and share the download link of that PBI file.
- bdehningPost Prodigy
As I use this
IF (ISINSCOPE( 'InjuryCause'[Cause Grouping]),RANKX (CALCULATETABLE (VALUES ( 'InjuryCause'[Cause Grouping]),ALLSELECTED ( 'InjuryCause'[Cause Grouping] )),[Count of Total Gross Incurred],,DESC,DENSE)
)and get ties.Now, I just want to use the [Sum of Total Gross Incurred] of each Ranked 'InjuryCause'[Cause Grouping] to break the ties and need help to add that to the measure. - bdehningPost Prodigy
I have reworked the measure and now I have this
Rank Cause Grouping Count =RANKX(ALLSELECTED(InjuryCause[Cause Grouping]),CALCULATE(COUNT(LossRunToExcel[Total Gross Incurred])),,DESC, Dense)Now I just need to come up with the rest to break ties and I want to use SUM(LossRunToExcel[Total Gross Incurred] to break the ties.