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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate and Store Rolling Total in DAX

Hello all,

 

I'm trying to calculate a rolling sum over a 5 day time period and store that sum for each date in my table. I've created a sample data set that shows the relevant calculations in excel. I have tried to implement a rolling total using multiple online sources, but nothing seems to work. I have successfully created the 'All Lots [lbs]' column to total the smaller values, but cannot figure out the rolling sum. Due to other calculation constraints, I must do this calculation with DAX, not PowerQuery M. I would greatly appreciate any help!

 

(*) is used here as a placeholder, nothing more.

holliebollie_0-1664211409755.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

I have created a simple sample, please refer to it to see if it helps you.

Create 2 columns.

 

all lots = 'Table'[Lot 1]+'Table'[Lot 2]+'Table'[Lot 3]

 

5 day rolling total =
VAR _5day = 'Table'[date] + 4
RETURN
    CALCULATE (
        SUM ( 'Table'[all lots] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] <= _5day
                && 'Table'[date] >= EARLIER ( 'Table'[date] )
        )
    )

vpollymsft_0-1664249342202.png

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

I have created a simple sample, please refer to it to see if it helps you.

Create 2 columns.

 

all lots = 'Table'[Lot 1]+'Table'[Lot 2]+'Table'[Lot 3]

 

5 day rolling total =
VAR _5day = 'Table'[date] + 4
RETURN
    CALCULATE (
        SUM ( 'Table'[all lots] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] <= _5day
                && 'Table'[date] >= EARLIER ( 'Table'[date] )
        )
    )

vpollymsft_0-1664249342202.png

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Works like a charm, thank you for your help!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.