Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi!
I have been trying to figure out a previous month- DAX function that takes into account that in January previous month's year is not the same as the current month's year.
I am currently using this and this does work when it is not January:
IsPreviousMonth = IF(AND(MONTH(MarketingMonthly[Date]) =MONTH(TODAY()) -1,YEAR(MarketingMonthly[Date]) =YEAR(TODAY())),"Previous","Other")
However, in January it will be broken since previous month's year should be year -1 and not the current year.
Does anybody know how to do this? Thank you in advance!
Solved! Go to Solution.
Thanks @sdjensen! I actually just figured this out like this:
IsPreviousMonth = IF(MarketingMonthly[YearMonth]=FORMAT(DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())),"YYYY/MM"),"Previous","Other")
Problem solved 🙂
Add an IF to the calculation that check if the month is january - if true handle the calculation differently else do what do now.
Thanks @sdjensen! I actually just figured this out like this:
IsPreviousMonth = IF(MarketingMonthly[YearMonth]=FORMAT(DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())),"YYYY/MM"),"Previous","Other")
Problem solved 🙂
User | Count |
---|---|
101 | |
90 | |
80 | |
71 | |
69 |
User | Count |
---|---|
114 | |
97 | |
97 | |
73 | |
72 |