Forum Discussion
Anonymous
6 years agoNot applicable
IF Statement help
Good afternoon, Can someone tell me why this is not working? IF ( YEAR( 'Casino Project Feb 2020'[Date] ) = YEAR (LASTDATE('Casino Project Feb 2020'[Date])) && MONTH( 'Casino Project Feb 2020...
- Anonymous6 years ago
Anonymous
This is because lastdate returns the current row, you will need to add All(table) as the context:
Column = var Lastdate_= CALCULATE(LASTDATE('Casino Project Feb 2020'[Date]),ALL('Casino Project Feb 2020')) Return IF(YEAR( 'Casino Project Feb 2020'[Date] ) = YEAR (Lastdate_) && MONTH( 'Casino Project Feb 2020'[Date]) = MONTH (Lastdate_), "Yes","No")Best regards
Paul Zheng
Anonymous
6 years agoNot applicable
ahmedoye, In the second line, do you mean:
VAR SelectedMonth = MONTH(SELECTEDVALUE(Casino Project Feb 2020'[Date] ))
I changed it to Month and now I am getting all "no"'s so it still isn't doing it correctly.... Do you have any other thoughts? Thank you so much for looking at this.
ahmedoye
Responsive Resident
6 years agoAnonymous , I figure you are doing this inside a Calculated Column. Edit your Initial DAX to look like this:
IF (
YEAR( 'Casino Project Feb 2020'[Date] ) = YEAR (LASTDATE(ALL('Casino Project Feb 2020'[Date])))
&& MONTH( 'Casino Project Feb 2020'[Date]) = MONTH (LASTDATE(ALL('Casino Project Feb 2020'[Date]))),
"Yes",
"No"
)
If this solution works for you, kindly give a kudo and mark it as the solution to enable others benefit from it.