- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Get the average sales value based on last 7 days but if there are no sales there is no entry
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I forgot to mention, I have a calendar table connected to this sales table

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 )

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 )

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I forgot to mention, I have a calendar table connected to this sales table

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
07-27-2024 05:45 AM | |||
05-05-2024 08:01 AM | |||
07-26-2024 12:03 AM | |||
03-29-2023 01:53 AM | |||
07-13-2022 12:10 PM |
User | Count |
---|---|
24 | |
12 | |
11 | |
10 | |
9 |
User | Count |
---|---|
18 | |
14 | |
13 | |
12 | |
10 |