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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

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
Super User
Super User

@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

 

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

 

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!

Hi @MAVIE 
Please provide sample data to work with

tamerj1
Super User
Super User

Hi @MAVIE 

how does your report look like?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.