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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Cummulative subtraction of two measures

Hi Experts, 

 

I'm trying to create a measure that calculates the cummulative subtraction of two measures.

 

I have the following three measures:

 

lpf_not_solved = SUM('Weekly LPF'[Not solved curve])
baseline_solved = SUM('LPF Baseline test'[Baseline_Solved_Value])
cum_subtract = [lpf_not_solved] - [baseline_solved]

 

 

cum_subtract is not correct and I have tried multiple things to achieve the desired output without luck. 

The expected output is visualized below:

 

2023-03-14_19-20-00.png

 

 

 

 

 

 

 

 

 

Both 'Weekly LPF' and 'LPF Baseline test' have a one-to-many relationship to the DateTable:

woyczi_1-1678818736108.png

 

Any idea how to solve this? 

Thank you for your input and time! It's much appreciated.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

please try

cum_subtract =
VAR CurrentDate =
    MAX ( DateTable[Date] )
VAR SelectedDates =
    ALLSELECTED ( DateTable[Date] )
VAR WeeklyTable =
    ADDCOLUMNS ( SelectedDates, "@NotSolved", [lpf_not_solved] )
VAR T1 =
    FILTER (
        WeeklyTable,
        DateTable[Date] <= CurrentDate
            && [@NotSolved] <> BLANK ()
    )
VAR T2 =
    TOPN ( 1, T1, DateTable[Date] )
VAR NotSolved =
    MAXX ( T2, [@NotSolved] )
VAR BaselineTable =
    ADDCOLUMNS ( SelectedDates, "@Solved", [baseline_solved] )
VAR T3 =
    FILTER ( BaselineTable, DateTable[Date] <= CurrentDate )
VAR T4 =
    FILTER ( T3, [@Solved] = BLANK () )
VAR LastBlank =
    MAXX ( T4, DateTable[Date] )
VAR T5 =
    FILTER ( T3, DateTable[Date] > LastBlank )
VAR Solved =
    SUMX ( T5, [@Solved] )
RETURN
    NotSolved - Solved

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 

please try

cum_subtract =
VAR CurrentDate =
    MAX ( DateTable[Date] )
VAR SelectedDates =
    ALLSELECTED ( DateTable[Date] )
VAR WeeklyTable =
    ADDCOLUMNS ( SelectedDates, "@NotSolved", [lpf_not_solved] )
VAR T1 =
    FILTER (
        WeeklyTable,
        DateTable[Date] <= CurrentDate
            && [@NotSolved] <> BLANK ()
    )
VAR T2 =
    TOPN ( 1, T1, DateTable[Date] )
VAR NotSolved =
    MAXX ( T2, [@NotSolved] )
VAR BaselineTable =
    ADDCOLUMNS ( SelectedDates, "@Solved", [baseline_solved] )
VAR T3 =
    FILTER ( BaselineTable, DateTable[Date] <= CurrentDate )
VAR T4 =
    FILTER ( T3, [@Solved] = BLANK () )
VAR LastBlank =
    MAXX ( T4, DateTable[Date] )
VAR T5 =
    FILTER ( T3, DateTable[Date] > LastBlank )
VAR Solved =
    SUMX ( T5, [@Solved] )
RETURN
    NotSolved - Solved
Greg_Deckler
Community Champion
Community Champion

@Anonymous See if this helps: Better Running Total - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.