Forum Discussion
3maris
3 years agoFrequent Visitor
Is RANKX the right answer to this problem?
Hello, I have a dashboard where the user can select 2 different date ranges and compare the same metric. Everything is working fine but now I would like to plot these data in a line chart for compa...
Anonymous
3 years agoNot applicable
Hi 3maris ,
You can create a measure as below to get it, please find the details in the attachment.
Rank =
VAR _selcountryIso =
SELECTEDVALUE ( 'Table'[countryIso] )
VAR _rankv1 =
RANKX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[countryIso] = _selcountryIso
&& [metric 1] <> BLANK ()
),
CALCULATE ( MAX ( 'Table'[date] ) ),,ASC
)
VAR _rankv2 =
RANKX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[countryIso] = _selcountryIso
&& [metric 2] <> BLANK ()
),
CALCULATE ( MAX ( 'Table'[date] ) ),,ASC
)
VAR _rank1 =
IF ( [metric 1] = BLANK (), BLANK (), _rankv1 )
VAR _rank2 =
IF ( [metric 2] = BLANK (), BLANK (), _rankv2 )
VAR _rank =
IF ( ISBLANK ( _rank1 ), _rank2, _rank1 )
RETURN
IF ( ISINSCOPE ( 'Table'[date] ), _rank, BLANK () )
Best Regards