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.
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))
User | Count |
---|---|
28 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
35 | |
14 | |
12 | |
9 | |
7 |