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
learning_pbi_11
New Member

Subtracting measures based on different filters not working

I am trying to subtract three measures and have the result show the same value in every row. The formula below returns 

VAR Test_Retained_earnings =
        CALCULATE(
                           Running_Total_ASSETS-
                           YTD_Net_Income_Acct_3900 -
                           Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings,
                           ALL('Balance Sheet Information' )
                           )
       RETURN Test_Retained_earnings
 
 
Below is the output in a matrix visual. 
learning_pbi_11_0-1727548096463.png
I would like BS_Running_Total6 to return ($1,751.36) for every value, not just the total. What filter must I apply to get this? The entire formula is pasted below: 

BS_Running_Total6 =

VAR _CurrentMonth = MONTH(MAX('Calendar'[Date] ) )
VAR _CurrentYear = YEAR(MAX('Calendar'[Date] ) )

VAR YTD_Net_Income_Acct_3900 =
    CALCULATE(
        SUM('Balance Sheet Information'[BS_$_Amount] ),
        'Balance Sheet Information'[AcctNum] = 3900,
        MONTH('Calendar'[Date] ) <= _CurrentMonth,
        YEAR('Calendar'[Date] ) = _CurrentYear
    )            

VAR MaxBSDate = MAX('Calendar'[Date] )
VAR MinDate =
    DATESINPERIOD(
        'Reference_Calendar'[Date],
        MaxBSDate,
        -240,
        MONTH
    )

VAR  Running_Total_All_Except_3900=
    CALCULATE(
        SUM('Balance Sheet Information'[BS_$_Amount] ),
        REMOVEFILTERS('Calendar'),
            KEEPFILTERS(MinDate ),
            USERELATIONSHIP('Calendar'[Date],'Reference_Calendar'[Date] )    
    )

VAR  Running_Total_ASSETS=
    CALCULATE(
        SUM('Balance Sheet Information'[BS_$_Amount] ),
        'Balance Sheet Information'[AcctNum] < 2000,
        REMOVEFILTERS('Calendar'),
            KEEPFILTERS(MinDate ),
            USERELATIONSHIP('Calendar'[Date],'Reference_Calendar'[Date] )    
    )

VAR  Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings =
    CALCULATE(
        SUM('Balance Sheet Information'[BS_$_Amount] ),
        'Balance Sheet Information'[AcctNum] >= 2000,
        'Balance Sheet Information'[AcctNum] <> 3500,
        'Balance Sheet Information'[AcctNum] <> 3900,
        REMOVEFILTERS('Calendar'),
            KEEPFILTERS(MinDate ),
            USERELATIONSHIP('Calendar'[Date],'Reference_Calendar'[Date] )    
    )


VAR Test_Retained_earnings =
        CALCULATE(Running_Total_ASSETS - YTD_Net_Income_Acct_3900 - Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings,
        ALL('Balance Sheet Information' )
            )




RETURN Test_Retained_earnings
4 REPLIES 4
rajendraongole1
Super User
Super User

Hi @learning_pbi_11 -You are almost there with your formula. The main adjustment is ensuring that ALL filters are removed across the table during the final calculation.

 

BS_Running_Total6 =

VAR _CurrentMonth = MONTH(MAX('Calendar'[Date]))
VAR _CurrentYear = YEAR(MAX('Calendar'[Date]))

VAR YTD_Net_Income_Acct_3900 =
CALCULATE(
SUM('Balance Sheet Information'[BS_$_Amount]),
'Balance Sheet Information'[AcctNum] = 3900,
MONTH('Calendar'[Date]) <= _CurrentMonth,
YEAR('Calendar'[Date]) = _CurrentYear
)

VAR MaxBSDate = MAX('Calendar'[Date])
VAR MinDate =
DATESINPERIOD(
'Reference_Calendar'[Date],
MaxBSDate,
-240,
MONTH
)

VAR Running_Total_ASSETS =
CALCULATE(
SUM('Balance Sheet Information'[BS_$_Amount]),
'Balance Sheet Information'[AcctNum] < 2000,
REMOVEFILTERS('Calendar'),
KEEPFILTERS(MinDate),
USERELATIONSHIP('Calendar'[Date], 'Reference_Calendar'[Date])
)

VAR Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings =
CALCULATE(
SUM('Balance Sheet Information'[BS_$_Amount]),
'Balance Sheet Information'[AcctNum] >= 2000,
'Balance Sheet Information'[AcctNum] <> 3500,
'Balance Sheet Information'[AcctNum] <> 3900,
REMOVEFILTERS('Calendar'),
KEEPFILTERS(MinDate),
USERELATIONSHIP('Calendar'[Date], 'Reference_Calendar'[Date])
)

VAR Test_Retained_earnings =
Running_Total_ASSETS -
YTD_Net_Income_Acct_3900 -
Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings

RETURN
CALCULATE(
Test_Retained_earnings,
REMOVEFILTERS('Balance Sheet Information'),
REMOVEFILTERS('Calendar') -- Ensures same value across all rows
)

 

hope this works at your end.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hmm - I copied the formula you provided and renamed it "BS_Running_Total7" and it returns the same result. 

learning_pbi_11_0-1727556921605.png

I am not sure why it is still doing this? Repasting the formula below so you can see it is unchanged: 

BS_Running_Total7 =

VAR _CurrentMonth = MONTH(MAX('Calendar'[Date]))
VAR _CurrentYear = YEAR(MAX('Calendar'[Date]))

VAR YTD_Net_Income_Acct_3900 =
CALCULATE(
SUM('Balance Sheet Information'[BS_$_Amount]),
'Balance Sheet Information'[AcctNum] = 3900,
MONTH('Calendar'[Date]) <= _CurrentMonth,
YEAR('Calendar'[Date]) = _CurrentYear
)

VAR MaxBSDate = MAX('Calendar'[Date])
VAR MinDate =
DATESINPERIOD(
'Reference_Calendar'[Date],
MaxBSDate,
-240,
MONTH
)

VAR Running_Total_ASSETS =
CALCULATE(
SUM('Balance Sheet Information'[BS_$_Amount]),
'Balance Sheet Information'[AcctNum] < 2000,
REMOVEFILTERS('Calendar'),
KEEPFILTERS(MinDate),
USERELATIONSHIP('Calendar'[Date], 'Reference_Calendar'[Date])
)

VAR Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings =
CALCULATE(
SUM('Balance Sheet Information'[BS_$_Amount]),
'Balance Sheet Information'[AcctNum] >= 2000,
'Balance Sheet Information'[AcctNum] <> 3500,
'Balance Sheet Information'[AcctNum] <> 3900,
REMOVEFILTERS('Calendar'),
KEEPFILTERS(MinDate),
USERELATIONSHIP('Calendar'[Date], 'Reference_Calendar'[Date])
)

VAR Test_Retained_earnings =
Running_Total_ASSETS -
YTD_Net_Income_Acct_3900 -
Running_Total_Liabilities_Equity_less_NetIncome_less_RetainedEarnings

RETURN
CALCULATE(
Test_Retained_earnings,
REMOVEFILTERS('Balance Sheet Information'),
REMOVEFILTERS('Calendar') -- Ensures same value across all rows
)

I also tried removing filters from the 'reference_calendar' and that did not work either

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.

Top Solution Authors