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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
MAVIE
Helper I
Helper I

Cumulative Total with Dates Sliced by Separate Table

Hi All,

I'm trying to build a dynamic cumulative totals measure, where the date dimension is able to be sliced by the data ranges from an iterations dimension.  The measure the I'm working off of is the following, which lets me slice the dates to get the correct results: 

CALCULATE (
    SUM ( FactTimeRegistrations[Hours] ),
    FILTER ( ALLSELECTED ( DimDate[Date] ) , DimDate[Date] <= MAX ( DimDate[Date] ) )
)

 However, I want to add an additional filter to be able to slice the date based off of the date range from a given iteration, but I have been unsuccessful so far. 
The three tables that the meassure would be using are these: Picture1.png
Any help would be greatly appreciated!

1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

HI @MAVIE 
Please try

Hours RT =
VAR T1 =
    FILTER ( ALLSELECTED ( DimDate[Date] ), DimDate[Date] <= MAX ( DimDate[Date] ) )
VAR StartDate =
    MAXX ( FactTimeRegistrations, RELATED ( DimIterations[StartDate] ) )
VAR EndDate =
    MAXX ( FactTimeRegistrations, RELATED ( DimIterations[EndDate] ) )
VAR T2 =
    CALENDAR ( StartDate, EndDate )
RETURN
    CALCULATE ( SUM ( FactTimeRegistrations[Hours] ), INTERSECT ( T1, T2 ) )

View solution in original post

8 REPLIES 8
tamerj1
Community Champion
Community Champion

@MAVIE 
First create realtionship as follows

1.png

Then use

Hours RT =
VAR T1 =
    FILTER ( ALLSELECTED ( DimDate[Date] ), DimDate[Date] <= MAX ( DimDate[Date] ) )
VAR T2 =
    CALENDAR (
        RELATED ( DimIterations[StartDate] ),
        RELATED ( DimIterations[EndDate] )
    )
RETURN
    CALCULATE ( SUM ( FactTimeRegistrations[Hours] ), INTERSECT ( T1, T2 ) )

Hi @tamerj1 

I should have clarified the relationship. Iterations if connected to TimeRegistrations in this manner: 

MAVIE_2-1652773778829.png

 


Also the chart that I'm creating looks as such, which has been sliced on the desired iteration. The issue then is that that have data point from before the iteration which should not be included in the calculation.
Picture3.png

 

tamerj1
Community Champion
Community Champion

Hi @MAVIE 
The same code above shall remain applicable. Please check and let me know which results you get. Thank you

Using that measure I get the following error

MAVIE_0-1652777520480.png

 

tamerj1
Community Champion
Community Champion

HI @MAVIE 
Please try

Hours RT =
VAR T1 =
    FILTER ( ALLSELECTED ( DimDate[Date] ), DimDate[Date] <= MAX ( DimDate[Date] ) )
VAR StartDate =
    MAXX ( FactTimeRegistrations, RELATED ( DimIterations[StartDate] ) )
VAR EndDate =
    MAXX ( FactTimeRegistrations, RELATED ( DimIterations[EndDate] ) )
VAR T2 =
    CALENDAR ( StartDate, EndDate )
RETURN
    CALCULATE ( SUM ( FactTimeRegistrations[Hours] ), INTERSECT ( T1, T2 ) )

Hi @tamerj1 

This measure seems to work as intended. If anything else goes wrong, I'll try to share some test data with you. 

Thank you very much for your help!

tamerj1
Community Champion
Community Champion

Hi @MAVIE 
Please provide sample data to work with

tamerj1
Community Champion
Community Champion

Hi @MAVIE 

how does your report look like?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

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

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.