Forum Discussion
Beckster
5 years agoFrequent Visitor
Help with Complex Rank
Hi Guys Am hoping can help guide me in the right direction with some ranking. I've spent far too long trying to get this to work so need some help. I have a table, along with a dax measure to ...
- 5 years ago
Anonymous
5 years agoNot applicable
Hi Beckster ,
You can follow the below steps to get it, please find the details in the attachment.
1. Create a date table
2. Create a measure as below to get the rank
Rank = RANKX (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[year] = MAX ( 'Table'[year] ) ),
CALCULATE ( SUM ( 'Table'[$] ) ),
,
DESC,
DENSE
)
3. Create two measures to get the sum of $ for top 2 and ids for top 2 in latest year separately
Total for Top 2 = SUMX ( FILTER('Table',[Rank]<=2&&'Table'[year]=SELECTEDVALUE('Date'[Year])), [$] )Total for ids =
VAR _maxyear =
CALCULATE ( MAX ( 'Table'[year] ), ALLSELECTED ( 'Table'[year] ) )
VAR _tab =
CALCULATETABLE (
VALUES ( 'Table'[id] ),
FILTER ( 'Table', 'Table'[year] = _maxyear && [Rank] <= 2 )
)
RETURN
SUMX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[id]
IN _tab
&& 'Table'[year] = SELECTEDVALUE ( 'Date'[Year] )
),
[$]
)
Best Regards
Beckster
5 years agoFrequent Visitor
Thank you so much for your help! 🙂