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
Hi there,
I am trying to calculate a measure for the average total, by date, over the past seven dates. I want this measure to still give me the correct seven day average no matter what date slicers are chosen.
Below is my workings, but it seems to just give me the total for that day, and not the average total of the past seven days.
I have a custom date table sitting over my date table, hence 'custom date'.
Any help to sort this out would be appreciated:
Solved! Go to Solution.
Hi @greenskmachine2 ,
This is because the context of Date[Calendar_Date] hasn't be removed and you can try this method.
7 Day Average =
var _maxDate = LASTDATE(CalendarTable[Date])
VAR _minDate = _maxDate-7
RETURN
CALCULATE(
AVERAGE(Sales[Volume]),'Sales'[Date]>=_minDate&&'Sales'[Date]<=_maxDate,ALL('Sales'))
Best regards,
Mengmeng Li
Try
7 Day Average =
VAR MaxDate =
MAX ( 'Date'[Calendar_Date] )
VAR Result =
AVERAGEX (
DATESINPERIOD ( 'Date'[Calendar_Date], MaxDate, -7, DAY ),
CALCULATE ( SUM ( Sales[Volume] ), REMOVEFILTERS ( 'Custom Date' ) )
)
RETURN
Result
Hi @greenskmachine2 ,
This is because the context of Date[Calendar_Date] hasn't be removed and you can try this method.
7 Day Average =
var _maxDate = LASTDATE(CalendarTable[Date])
VAR _minDate = _maxDate-7
RETURN
CALCULATE(
AVERAGE(Sales[Volume]),'Sales'[Date]>=_minDate&&'Sales'[Date]<=_maxDate,ALL('Sales'))
Best regards,
Mengmeng Li
HI,
Please try this code :
var _maxDate = LASTDATE(Date[Calendar_Date])
var min_Date=_maxDate-6
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 |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |
| User | Count |
|---|---|
| 22 | |
| 20 | |
| 20 | |
| 14 | |
| 14 |