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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
MXSven
Helper I
Helper I

Rolling Sum for a subset of data

Hi Everybody,

I am struggling with a DAX Formula:

Calculation works for the overall time range, as you can see in the table,
but it doesn't work for specified time range (15th to 23rd ).

The rolling sum for this time range should start with 0 instead of 1

 

 

MXSven_0-1708328578650.png

 

This is my DAX Formula:

 

Cumulative Rolling Sum Value_B =
CALCULATE(
    SUM('Sheet1'[Value_B]),
    FILTER(
        ALL('Sheet1'),
        'Sheet1'[Date] <= MAX('Sheet1'[Date])
 
    )
)

 

Any ideas what I am doing wrong ?

2 REPLIES 2
123abc
Community Champion
Community Champion

It seems like you're trying to calculate a cumulative rolling sum for a specific time range in your data using DAX. The issue you're encountering is that your current formula calculates the rolling sum starting from the beginning of the dataset, whereas you want it to start from 0 for a specified time range.

To achieve the desired result, you need to modify your DAX formula to conditionally start the rolling sum from 0 for the specified time range. You can achieve this by adding an additional condition to your FILTER function.

Here's how you can modify your DAX formula:

 

 

Cumulative Rolling Sum Value_B =
VAR StartDate = DATE(2024, 1, 15)
VAR EndDate = DATE(2024, 1, 23)
RETURN
CALCULATE(
IF(
MIN('Sheet1'[Date]) > StartDate,
0,
SUM('Sheet1'[Value_B])
),
FILTER(
ALL('Sheet1'),
'Sheet1'[Date] <= MAX('Sheet1'[Date]) &&
'Sheet1'[Date] >= StartDate &&
'Sheet1'[Date] <= EndDate
)
)

 

 

In this modified formula:

  • I used two variables, StartDate and EndDate, to define your specified time range.
  • I used the IF function to check if the minimum date in your data is greater than the start date of the specified time range. If it is, the rolling sum starts from 0; otherwise, it calculates the sum normally.
  • I adjusted the FILTER function to include the conditions for the specified time range (between 15th and 23rd January 2024).

Please replace the StartDate and EndDate with your actual start and end dates. This formula should now calculate the cumulative rolling sum starting from 0 for the specified time range.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Thanks, 123abc.
I tried your proposed solution, but it is not calculating as I expected

 

Cumulative Rolling Sum Value_B =
VAR StartDate = MIN('Sheet1'[Date])
VAR EndDate = MAX('Sheet1'[Date])
RETURN
CALCULATE(
IF(
MIN('Sheet1'[Date]) > StartDate,
0,
SUM('Sheet1'[Value_B])
),
FILTER(
ALL('Sheet1'),
'Sheet1'[Date] <= MAX('Sheet1'[Date]) &&
'Sheet1'[Date] >= StartDate &&
'Sheet1'[Date] <= EndDate
)
)

 

The only thing I did differently was to retrieve the start date and end date from the sliders, and I checked the values.

MXSven_0-1708413934338.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.