Forum Discussion
Creating a calculated column for the latest and previous date based on a column and a dynamic select
- Anonymous4 years ago
Hi sridharpolina ,
Please change the measure to a column.
Column = var _rankx=RANKX(filter(ALLSELECTED('Table'),'Table'[State]=EARLIER('Table'[State])),'Table'[AsOfDate],,DESC,Dense) RETURN IF(_rankx=1,"Latest Runtime",IF(_rankx=2,"Previous Runtime",FORMAT(('Table'[AsOfDate]),"General Date")))_Rank_P = VAR _rank = RANKX ( FILTER ( 'Table' , OR(('Table'[Flg] = "P"),Table[State]=EARLIER(Table[State]))), 'Table'[AsOfDate],, DESC, DENSE ) VAR _isP = IF ( 'Schedules'[Flg] = "P" , _rank, BLANK () ) RETURN _isPBest Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi sridharpolina ,
Please have a try.
Create a measure.
Measure =
VAR _rankx =
RANKX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[State] = SELECTEDVALUE ( 'Table'[State] )
),
CALCULATE ( MAX ( 'Table'[AsOfDate] ) ),
,
DESC,
DENSE
)
RETURN
IF (
_rankx = 1,
"Latest Runtime",
IF (
_rankx = 2,
"Previous Runtime",
FORMAT ( MAX ( 'Table'[AsOfDate] ), "General Date" )
)
)
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks for all your help but I need a calculated column as an output since I need to use that column in a slicer. I tried to rank using the DAX code below but its not giving me the right output. Can you modify that query to reflect the state so I could get the desired output as a calculated column
_Rank_P =
VAR _rank =
RANKX ( FILTER ( ALL ( 'Table' ), OR(('Table'[Flg] = "P"),Table[State]=SELECTEDVALUE(Table[State]))), 'Table'[AsOfDate],, DESC, DENSE )
VAR _isP =
IF ( 'Schedules'[Flg] = "P" , _rank, BLANK () )
RETURN
_isP
- Anonymous4 years agoNot applicable
Hi sridharpolina ,
Please change the measure to a column.
Column = var _rankx=RANKX(filter(ALLSELECTED('Table'),'Table'[State]=EARLIER('Table'[State])),'Table'[AsOfDate],,DESC,Dense) RETURN IF(_rankx=1,"Latest Runtime",IF(_rankx=2,"Previous Runtime",FORMAT(('Table'[AsOfDate]),"General Date")))_Rank_P = VAR _rank = RANKX ( FILTER ( 'Table' , OR(('Table'[Flg] = "P"),Table[State]=EARLIER(Table[State]))), 'Table'[AsOfDate],, DESC, DENSE ) VAR _isP = IF ( 'Schedules'[Flg] = "P" , _rank, BLANK () ) RETURN _isPBest Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly