Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |