Forum Discussion
Replacing EARLIER functionality to work in a measure
Oodi , Try using below measure
HomeGameNumber =
VAR CurrentHomeTeam = MAX(TeamSchedule_[HomeTeam])
VAR CurrentGameDate = MAX(TeamSchedule_[gameDate])
RETURN
RANKX(
FILTER(
TeamSchedule_,
TeamSchedule_[HomeTeam] = CurrentHomeTeam
),
TeamSchedule_[gameDate],
,
ASC,
DENSE
)
HomeGameNumberPerSeason =
VAR CurrentHomeTeam = MAX(TeamSchedule_[HomeTeam])
VAR CurrentGameDate = MAX(TeamSchedule_[gameDate])
VAR CurrentSeason = MAX(TeamSchedule_[season])
RETURN
RANKX(
FILTER(
TeamSchedule_,
TeamSchedule_[HomeTeam] = CurrentHomeTeam &&
TeamSchedule_[season] = CurrentSeason
),
TeamSchedule_[gameDate],
,
ASC,
DENSE
)
FinalHomeGameNumber =
IF(
ISFILTERED(AuxSeason[Season]),
[HomeGameNumberPerSeason],
[HomeGameNumber]
)
Thanks for the suggestion. Tried it out and the measure returns error:
A single value for column 'gameDate' in table 'TeamSchedule_' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
The error is caused by the RANKX() Expression TeamSchedule_[GameDate] and goes away with SELECTEDVALUE(TeamSchedule_[GameDate]) but this does not return the correct query i.e. the same the calculated column returns using EARLIER().