Forum Discussion
IF Statement DAX Month
- 7 years ago
Hi sdas028 ,
We can create a calculated column to make sure the reuslt is correct if there are different years in your fact table.
YTD = var monthyear = YEAR(Table1[Posting date])*100+MONTH(Table1[Posting date]) var _today = YEAR(TODAY())*100+MONTH(TODAY()) return IF(monthyear<=_today,"Yes","No")
For more details, please check the pbix as attached.
Regards,
Frank
Note that Anonymous and mine do two different things. His will tell you any date older than today. Mine will tell you any month older than today. So Feb 1 is not older than today because month(2/1/2019) is not less than month(today()) (assuming today is any day in the month of Feb 2019.
Not sure which you need. Your original example left some room for interpretation. :-)
Hi Edhans,
Thanks so much for your answer this seems to be what I need, is it possible to have it less than or equal to todays Month?
So that February is still Yes YTD?
Also apologies for the misinterpretation!
Thanks,
Sophie
- v-frfei-msft7 years agoCommunity Support
- sdas0287 years agoHelper I
Hi Frank,
Yes absolutely! This is actually what I ended up using for the solution so thank you very much! :)
Apologies I always forget to go back and close off the request, will do that now
Thanks,
Sophie