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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EMSSS22
Helper I
Helper I

Writing a measure to subtract two columns same table with filters

Hi 

 

I have 2 columns that i would like to subtract from one another after applied filters.

 

Eg.

 

Column B (with version type x and month number x) - Column A (with version type x and month number x)

 

 

What I currently have and is giving me wrong answer:

 

ForecastCMVariance = CALCULATE(SUM(FilteredCommercial[Forecast]) - CALCULATE(SUM(FilteredCommercial[Capital Rental])))

 

How do I go about writing this dax?

 

DAX filter 

4 REPLIES 4
tamerj1
Super User
Super User

Hi @EMSSS22 

Are version type and month number from the same table or different tables? What are the relationship between the tables? When you refer to "x" is it the same value used to filter both columns?

Hi 

 

Yes its the same table.

 

and

 

Yes the same filter needs to be applied to both columns.

 

Thanks 🙂

@EMSSS22 

Apologies for the late reply. Please try

ForecastCMVariance =
SUMX (
FILTER ( Commercial, Commercial[Version] = "x" && Commercial[month number] = y ),
Commercial[Forecast] - Commercial[Capital Rental]
)

johnt75
Super User
Super User

Try something like

ForecastCMVariance =
CALCULATE (
    SUMX (
        FilteredCommercial,
        FilteredCommercial[Forecast] - FilteredCommercial[Capital Rental]
    ),
    FilteredCommercial[Version] = "x",
    FilteredCommercial[month number] = y
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.