cancel
Showing results 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

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.

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] )
)
)
``````

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.

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] )
)
)
``````

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!

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.