The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I am trying to create a rolling 4 week average of the Actuals column and grouped on the State.
So startring at the bottom, the 4 week average for TX in the final row would be, (1+ 0 (no sales in week of may22) + 1+3) / 4 (number of weeks).
So in think for a given week and state observation, i would need to sum all 'Actual' values in a 4 week period including the current obersation, grouped by the State, then divide by the number of weeks.
Solved! Go to Solution.
Hi @Jacob1832 ,
Please try this measure.
Rolling 4 week average of the Actuals =
VAR _given_week =
MAX ( 'Table'[Week] )
VAR _sum =
CALCULATE (
SUM ( 'Table'[Actuals] ),
'Table'[Week] >= _given_week - 21
&& 'Table'[Week] <= _given_week
)
VAR _average =
DIVIDE ( _sum , 4 ) + 0
RETURN
_average
Attached PBIX file for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi @Jacob1832 ,
Please try this measure.
Rolling 4 week average of the Actuals =
VAR _given_week =
MAX ( 'Table'[Week] )
VAR _sum =
CALCULATE (
SUM ( 'Table'[Actuals] ),
'Table'[Week] >= _given_week - 21
&& 'Table'[Week] <= _given_week
)
VAR _average =
DIVIDE ( _sum , 4 ) + 0
RETURN
_average
Attached PBIX file for reference.
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |