Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Good afternoon,
Can someone tell me why this is not working?
Solved! Go to Solution.
@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 , try using this measure for a try:
VAR SelectedYear = YEAR(SELECTEDVALUE(Casino Project Feb 2020'[Date] ))
VAR SelectedMonth = YEAR(SELECTEDVALUE(Casino Project Feb 2020'[Date] ))
VAR LatestDate = MAX('Casino Project Feb 2020'[Date])
VAR LatestYear = YEAR(LatestDate)
VAR LatestMonth = MONTH(LatestDate)
RETURN IF(SelectedYear = LatestYear && SelectedMonth = LatestMonth, "Yes", "No")
if this Solution works for you, kindly kudo and mark as solution to enable others benefit from it.
@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.
@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 , I figure you are doing this inside a Calculated Column. Edit your Initial DAX to look like this:
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....
Also, the calculated column is returning "yes" for all rows even when it should be "no"
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |