Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
14 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
21 | |
13 | |
11 | |
10 | |
10 |