The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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!! 😅
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
23 | |
14 | |
13 | |
8 | |
8 |