Skip to main content
cancel
Showing results for
Search instead for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Rolling 4 week average by state

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.

1 ACCEPTED SOLUTION
Community Support

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

2 REPLIES 2
Community Support

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

Solution Specialist

## Helpful resources

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Join our Community Sticker Challenge

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

#### Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

#### Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors