Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello all, this is probably a very simple fix. I am trying to calcualte a rolling average for the last 7 days (R7) to smooth out our daily sales and transactions graphs.
While the measure I created is functiong properly, it is averaging all of the individual sales. What I am looking for, is to average the total daily sales. I have them grouped by type as well (GrubHub, Door Dash, Kiosk, Mobile, and Uber Eats). So again my formula is giving me the R7 but its giving me the R7 for order size versus daily totals. Please see below:
I have tried creating calculated columns for the 5 groups but the R7 spikes at the end. So I created 1 measure then used the Type coulmn as a way to group by.
Here is an example of a calculated column which lead to a spike on the last day:
Im sure there are multiple ways to solve this. We can solve the measure (R7 Sales) or the calculated columns (Door Dash R7 Sales). Either option is fine with me. Thank you in advance!
Solved! Go to Solution.
Hi @james_pease ,
You can create a measure as below to get the rolling average values:
R7 Sales =
VAR _max =
MAX ( 'Sales (unpivoted)'[Date] )
VAR _min = _max - 6
RETURN
IF (
_min < MINX ( ALLSELECTED ( 'Sales (unpivoted)' ), 'Sales (unpivoted)'[Date] ),
BLANK (),
DIVIDE (
CALCULATE (
COUNTROWS ( 'Sales (unpivoted)' ),
FILTER (
ALLSELECTED ( 'Sales (unpivoted)' ),
'Sales (unpivoted)'[Date] >= _min
&& 'Sales (unpivoted)'[Date] <= _max
)
),
7
)
)
In addition, you can refer the following links to get it.
Rolling AVG - 7 days =
CALCULATE (
SUM ( val_summary_by_day_source_tv_region[vals_booked] ) / 7,
DATESINPERIOD (
'Calendar Reference'[Date_2],
LASTDATE ( 'Calendar Reference'[Date_2] ),
-7,
DAY
),
ALLEXCEPT (
val_source_ref_lookup,
val_source_ref_lookup[val_business_category]
)
)
If the above one can't help you get the desired result, please provide some sample data in your table 'HVDN table call volume(main)' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi @james_pease ,
You can create a measure as below to get the rolling average values:
R7 Sales =
VAR _max =
MAX ( 'Sales (unpivoted)'[Date] )
VAR _min = _max - 6
RETURN
IF (
_min < MINX ( ALLSELECTED ( 'Sales (unpivoted)' ), 'Sales (unpivoted)'[Date] ),
BLANK (),
DIVIDE (
CALCULATE (
COUNTROWS ( 'Sales (unpivoted)' ),
FILTER (
ALLSELECTED ( 'Sales (unpivoted)' ),
'Sales (unpivoted)'[Date] >= _min
&& 'Sales (unpivoted)'[Date] <= _max
)
),
7
)
)
In addition, you can refer the following links to get it.
Rolling AVG - 7 days =
CALCULATE (
SUM ( val_summary_by_day_source_tv_region[vals_booked] ) / 7,
DATESINPERIOD (
'Calendar Reference'[Date_2],
LASTDATE ( 'Calendar Reference'[Date_2] ),
-7,
DAY
),
ALLEXCEPT (
val_source_ref_lookup,
val_source_ref_lookup[val_business_category]
)
)
If the above one can't help you get the desired result, please provide some sample data in your table 'HVDN table call volume(main)' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
The link you provided helped a ton! This is the resulting formula that did work, (the others provided sadly didnt).
@james_pease , Use a date table, joined with 'Sales (unpivoted)'[Date]
and try meausre like
R7 Sales =
CALCULATE(
AVERAGEX(Values('Sales (unpivoted)','Sales (unpivoted)'[Type]),calculate(Sum('Sales (unpivoted)'[Value])))
DATESINPERIOD('date'[Date], LASTDATE ('date'[Date]), -7, DAY),
)
Rolling Days Formula: https://youtu.be/cJVj5nhkKBw
Average of Rolling, Average of Snapshots: https://youtu.be/_pZRdLAJxxA
User | Count |
---|---|
20 | |
20 | |
14 | |
10 | |
8 |
User | Count |
---|---|
29 | |
28 | |
13 | |
12 | |
11 |