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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Jacob1832
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). 

Jacob1832_0-1654644539399.png

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
Anonymous
Not applicable

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

vcgaomsft_0-1655186090904.png

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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

vcgaomsft_0-1655186090904.png

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

vapid128
Solution Specialist
Solution Specialist

 

2022-06-07 174410.png

屏幕截图 2022-06-07 174605.png

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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