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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ace512
New Member

I have a running total measure and I just can't seem to get the correct value

Hello guys! I have a running total measure and I just can't seem to get the correct values. I tried different approaches I saw on the web. My running/cumulative total is giving the base measure as a result.
Here's my running total measure:

 

Cumulative Total Category CAB = 
SUMX(
    FILTER(ALLSELECTED('Cashflow A'[Date].[Month]),
    SELECTEDVALUE('Cashflow A'[Date].[Month]) <= MAX('Cashflow A'[Date].[Month])),[Total CAB])

Here's the base measure:
Total CAB = [Total Collections Sum] - [Total Category AB]

Total Collections Sum = 
CALCULATE(
    [Sum Amount], 
    FILTER(ALL('Cashflow A'), 
        'Cashflow A'[Path L1] = "Collections" && 'Cashflow A'[Date].[MonthNo] = SELECTEDVALUE('Cashflow A'[Date].[MonthNo])))

Total Category AB = 
(CALCULATE(
    [Sum Amount], 
    FILTER(ALL('Cashflow A'), 
        'Cashflow A'[Path L1] = "Total Category A" && 'Cashflow A'[Date].[MonthNo] = SELECTEDVALUE('Cashflow A'[Date].[MonthNo])))) + 
(CALCULATE(
    [Sum Amount], 
    FILTER(ALL('Cashflow A'), 
        'Cashflow A'[Path L1] = "Total Category B" && 'Cashflow A'[Date].[MonthNo] = SELECTEDVALUE('Cashflow A'[Date].[MonthNo]))))

 

Any help is appreciated. Thanks!
1 ACCEPTED SOLUTION
ray_ux
Memorable Member
Memorable Member

@ace512 hmm i recommend reading this: detailed breakdown of possibilities: https://www.daxpatterns.com/cumulative-total/

From what i can see: 

don't really need a SUMX for a cumulative total

-  Filtering all but then passing in selected value as the comparison is redundant as you're just evaluating the current line and making sure it is like itself ,you'll see what I mean if you swap out the sum

 

 

Total Collections Sum = 
CALCULATE(
    SELECTEDVALUE('Cashflow A'[Date].[MonthNo]), 
    FILTER(ALL('Cashflow A'), 
        'Cashflow A'[Path L1] = "Collections" && 'Cashflow A'[Date].[MonthNo] = SELECTEDVALUE('Cashflow A'[Date].[MonthNo])))

 

If it's returning more than 1 value it will be blank, but I suspect in the visual you posted above it will just show the current month column

View solution in original post

2 REPLIES 2
ray_ux
Memorable Member
Memorable Member

@ace512 hmm i recommend reading this: detailed breakdown of possibilities: https://www.daxpatterns.com/cumulative-total/

From what i can see: 

don't really need a SUMX for a cumulative total

-  Filtering all but then passing in selected value as the comparison is redundant as you're just evaluating the current line and making sure it is like itself ,you'll see what I mean if you swap out the sum

 

 

Total Collections Sum = 
CALCULATE(
    SELECTEDVALUE('Cashflow A'[Date].[MonthNo]), 
    FILTER(ALL('Cashflow A'), 
        'Cashflow A'[Path L1] = "Collections" && 'Cashflow A'[Date].[MonthNo] = SELECTEDVALUE('Cashflow A'[Date].[MonthNo])))

 

If it's returning more than 1 value it will be blank, but I suspect in the visual you posted above it will just show the current month column

Awesome. Thanks for this!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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