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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
rogerthat
Helper I
Helper I

Dax Measure to handle last month for DEC and Today() JAN

Hello,

 

 

I'm trying to count all records that have been created YTD, up till last month.

 

Meaning Jan-Oct.

Previous Month = MONTH(TODAY())-1

However, I'm trying to get the logic of when today is actually Janurary, would it be smart enough to get 12?

Or should I write an "if" to handle this stituation? And if so, how would I accomplish this. Kinda stuck here.

 

TIA~

 
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

No, it won't give you 12 when TODAY() is in January.

 

You can handle that case specifically,

 

Previous Month =
VAR CurrMonth = MONTH ( TODAY () )
RETURN
    IF ( CurrMonth = 1, 12, CurrMonth - 1 )

 

 

Or take a slightly different approach:

 

Previous Month = MONTH ( EOMONTH ( TODAY (), -1 ) )

 

 

Or use MOD:

 

Previous Month = MOD ( MONTH ( TODAY () ) - 2, 12 ) + 1

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

No, it won't give you 12 when TODAY() is in January.

 

You can handle that case specifically,

 

Previous Month =
VAR CurrMonth = MONTH ( TODAY () )
RETURN
    IF ( CurrMonth = 1, 12, CurrMonth - 1 )

 

 

Or take a slightly different approach:

 

Previous Month = MONTH ( EOMONTH ( TODAY (), -1 ) )

 

 

Or use MOD:

 

Previous Month = MOD ( MONTH ( TODAY () ) - 2, 12 ) + 1

 

I was able to get it right before your response, I circled back and forth haha but did something simialr to what you suggested!

 

Thanks!! 😅

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.