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.
Hi all,
I would like to have always the current last month displayed in this table like in the picture below. However, I don't want to select the current date every time, I want the measure to pull the previous month automatically.
This is currently my formula. But here I still need the date filter. I only ever need the previous month, all other months do not interest me in this matter.
How is this possible?
Thanks!
Solved! Go to Solution.
[prevMonth] =
var today_ = today()
// get the first day of the previous month
var dayStart = EOMONTH(today_, -2) + 1
// get the last day of the previous month
var dayEnd = EOMONTH(today_, -1)
var result =
CALCULATE(
sum( 'sales'[delivery quantity] ),
all( Kalender[Datum] ),
Kalender[Datum] >= dayStart,
Kalender[Datum] <= dayEnd
)
return
result
[prevMonth] =
var today_ = today()
// get the first day of the previous month
var dayStart = EOMONTH(today_, -2) + 1
// get the last day of the previous month
var dayEnd = EOMONTH(today_, -1)
var result =
CALCULATE(
sum( 'sales'[delivery quantity] ),
all( Kalender[Datum] ),
Kalender[Datum] >= dayStart,
Kalender[Datum] <= dayEnd
)
return
result
@Anonymous , Try like this. It will work for both selected and not selected
Switch Period =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = eomonth(_max,-1)
var _min = eomonth(_max,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))