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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors