Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
PhoenixBird66
Helper III
Helper III

DAX measure to return the Month Number from Previous 2 months

 

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?

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @PhoenixBird66 ,

 

Please try:

Measure = 
var now_month = MONTH(NOW())
return IF(now_month+10>12,now_month-2,now_month+10
)

V-lianl-msft_0-1610086530787.png

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @PhoenixBird66 ,

 

Please try:

Measure = 
var now_month = MONTH(NOW())
return IF(now_month+10>12,now_month-2,now_month+10
)

V-lianl-msft_0-1610086530787.png

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@PhoenixBird66 , Use today function itself

 

2MonthsAgo = FORMAT(eomonth(date(today(),-2),"mm")

or

2MonthsAgo = month(eomonth(date(today(),-2))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.