Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I need a DAX measure that will return the month number of 2 months prior to the current month (so today is January, and the Month Number is 01, but I want the Dax measure to return the month number for 2 months ago, which would be 11)
In order to do this previously I was using this measure:
2MonthsAgo = FORMAT([Today],"mm")-2
However, now that we're in January and the month number is 1, it's giving me the incorrect value of -1 instead of 11. When we're in February, I need the measure to return 12 (the Month number for December).
My [Today] meausure is Today = NOW() so the data type is uncategorised.
Welcoming any suggestions for how I should get around this issue?
Solved! Go to Solution.
Hi @PhoenixBird66 ,
Please try:
Measure =
var now_month = MONTH(NOW())
return IF(now_month+10>12,now_month-2,now_month+10
)
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @PhoenixBird66 ,
Please try:
Measure =
var now_month = MONTH(NOW())
return IF(now_month+10>12,now_month-2,now_month+10
)
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@PhoenixBird66 , Use today function itself
2MonthsAgo = FORMAT(eomonth(date(today(),-2),"mm")
or
2MonthsAgo = month(eomonth(date(today(),-2))
Thanks for the suggestions. Sadly neither work for me.
When I try the either suggestion i get the error "Too few arguments were passed to the DATE function. The minimum argument count for the function is 3."
@PhoenixBird66 , My bad try like
2MonthsAgo = FORMAT(eomonth(today(),-2),"mm")
or
2MonthsAgo = month(eomonth(today(),-2))
User | Count |
---|---|
103 | |
90 | |
78 | |
72 | |
68 |
User | Count |
---|---|
108 | |
96 | |
95 | |
74 | |
71 |