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.
I am wanting to have 3 visual cards that shows the previous MONTH YEAR and month before previous. What DAX meausre do I need to obtain this please? This is just simply the month and year name on a card.
I so far have the current month.
April 2023 and the measure is CurrentMonth = Format(Now(),"MMMM YYYY")
But now I need:
March 2023
February 2023
Any ideas on how I can achieve this please? Thanks
Solved! Go to Solution.
Hi,
One of ways to achieve this is to write measures like below.
Please check the below picture and the attached pbix file.
If you do not want to create a virtual calendar table inside the measure, then try using only two dax functions, those are EOMONTH DAX function and FORMAT DAX Function.
Prev month year: =
VAR _today =
TODAY ()
VAR _prevendofmonth =
EOMONTH ( _today, -1 )
VAR _prevprevendofmonth =
EOMONTH ( _today, -2 )
VAR _prevyear =
YEAR ( _today ) - 1
VAR _currentyear =
YEAR ( _today )
VAR _calendar =
ADDCOLUMNS (
CALENDAR ( DATE ( _prevyear, 1, 1 ), DATE ( _currentyear, 12, 31 ) ),
"@Month Year", FORMAT ( [Date], "mmmm yyyy" ),
"@Month Year sort", EOMONTH ( [Date], 0 )
)
VAR _monthyearcalendar =
SUMMARIZE ( _calendar, [@Month Year], [@Month Year sort] )
RETURN
MAXX (
FILTER ( _monthyearcalendar, [@Month Year sort] = _prevendofmonth ),
[@Month Year]
)
PrevPrev month year: =
VAR _today =
TODAY ()
VAR _prevendofmonth =
EOMONTH ( _today, -1 )
VAR _prevprevendofmonth =
EOMONTH ( _today, -2 )
VAR _prevyear =
YEAR ( _today ) - 1
VAR _currentyear =
YEAR ( _today )
VAR _calendar =
ADDCOLUMNS (
CALENDAR ( DATE ( _prevyear, 1, 1 ), DATE ( _currentyear, 12, 31 ) ),
"@Month Year", FORMAT ( [Date], "mmmm yyyy" ),
"@Month Year sort", EOMONTH ( [Date], 0 )
)
VAR _monthyearcalendar =
SUMMARIZE ( _calendar, [@Month Year], [@Month Year sort] )
RETURN
MAXX (
FILTER ( _monthyearcalendar, [@Month Year sort] = _prevprevendofmonth ),
[@Month Year]
)
Hi,
One of ways to achieve this is to write measures like below.
Please check the below picture and the attached pbix file.
If you do not want to create a virtual calendar table inside the measure, then try using only two dax functions, those are EOMONTH DAX function and FORMAT DAX Function.
Prev month year: =
VAR _today =
TODAY ()
VAR _prevendofmonth =
EOMONTH ( _today, -1 )
VAR _prevprevendofmonth =
EOMONTH ( _today, -2 )
VAR _prevyear =
YEAR ( _today ) - 1
VAR _currentyear =
YEAR ( _today )
VAR _calendar =
ADDCOLUMNS (
CALENDAR ( DATE ( _prevyear, 1, 1 ), DATE ( _currentyear, 12, 31 ) ),
"@Month Year", FORMAT ( [Date], "mmmm yyyy" ),
"@Month Year sort", EOMONTH ( [Date], 0 )
)
VAR _monthyearcalendar =
SUMMARIZE ( _calendar, [@Month Year], [@Month Year sort] )
RETURN
MAXX (
FILTER ( _monthyearcalendar, [@Month Year sort] = _prevendofmonth ),
[@Month Year]
)
PrevPrev month year: =
VAR _today =
TODAY ()
VAR _prevendofmonth =
EOMONTH ( _today, -1 )
VAR _prevprevendofmonth =
EOMONTH ( _today, -2 )
VAR _prevyear =
YEAR ( _today ) - 1
VAR _currentyear =
YEAR ( _today )
VAR _calendar =
ADDCOLUMNS (
CALENDAR ( DATE ( _prevyear, 1, 1 ), DATE ( _currentyear, 12, 31 ) ),
"@Month Year", FORMAT ( [Date], "mmmm yyyy" ),
"@Month Year sort", EOMONTH ( [Date], 0 )
)
VAR _monthyearcalendar =
SUMMARIZE ( _calendar, [@Month Year], [@Month Year sort] )
RETURN
MAXX (
FILTER ( _monthyearcalendar, [@Month Year sort] = _prevprevendofmonth ),
[@Month Year]
)
User | Count |
---|---|
15 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
30 | |
19 | |
12 | |
7 | |
5 |