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
Hello All,
I attempting to get the average sales for the last 7 days of a sales table like this:
| Item | Date | QTY |
| AA | 1/1 | 1 |
| AA | 1/2 | 2 |
| AA | 1/4 | 2 |
| AA | 1/6 | 2 |
The problem i'm running into is that If you Average() or Averagex() and use whichever date filter, you get the average of values that exist. Ideally, I would want the average including the 0 sales on 1/5,1/7 and 1/3 but those transaction don't appear in my table.
I would want a dax expression to result to this:
| Item | 7 Day Average |
| AA | 1 |
Solved! Go to Solution.
I forgot to mention, I have a calendar table connected to this sales table
Found a solution!
7 Day Moving Average =
VAR SelectedDate = MAX(Calendar[Date])
VAR StartDate = SelectedDate - 6 VAR TotalSales = CALCULATE ( SUM ( Sales[Amount] ), DATESINPERIOD ( Calendar[Date], StartDate, SelectedDate, DAY ) )
VAR TotalDays = COUNTROWS ( DATESINPERIOD ( Calendar[Date], StartDate, SelectedDate, DAY ) )
RETURN DIVIDE ( TotalSales, TotalDays, 0 )
Found a solution!
7 Day Moving Average =
VAR SelectedDate = MAX(Calendar[Date])
VAR StartDate = SelectedDate - 6 VAR TotalSales = CALCULATE ( SUM ( Sales[Amount] ), DATESINPERIOD ( Calendar[Date], StartDate, SelectedDate, DAY ) )
VAR TotalDays = COUNTROWS ( DATESINPERIOD ( Calendar[Date], StartDate, SelectedDate, DAY ) )
RETURN DIVIDE ( TotalSales, TotalDays, 0 )
I forgot to mention, I have a calendar table connected to this sales table
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 |
|---|---|
| 12 | |
| 9 | |
| 8 | |
| 5 | |
| 3 |
| User | Count |
|---|---|
| 28 | |
| 22 | |
| 20 | |
| 18 | |
| 12 |