Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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~
Solved! Go to Solution.
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
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!! 😅