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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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!! 😅
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 19 | |
| 17 | |
| 11 |