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
zebra123
Regular Visitor

Subtraction of two columns with different names

Hi,

I am trying to perform a subtraction of the same name value but in different columns. Also the name of the column is decided by a slicer. Is there a DAX measure equation to do this? So I want to subtract average of TRP performance factor of the CT40 from the average TRP performance factor of the TC25.

zebra123_0-1657819763947.png

zebra123_1-1657819776552.png

Thanks

 

1 ACCEPTED SOLUTION

Hi @zebra123 

 

Does all data come from the same table? Does the field in the slicer come from that table? Assume that all data is in the same table and that the expected result should be put in the same matrix, you can try below code to create a measure. Modify table and column names per your need. In my sample, "c" is the fixed one to be subtracted from. 

Difference = 
var _minuend = CALCULATE(AVERAGE('Table (2)'[Factor1]),ALLSELECTED('Table (2)'[Type]),'Table (2)'[Type] = "c")
var _subtrahend = AVERAGE('Table (2)'[Factor1])
return
_minuend - _subtrahend

vjingzhang_0-1658216457278.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

5 REPLIES 5
zebra123
Regular Visitor

Yes, I'm showing the data in a matrix visual. 

The data is stored in a table, but the data I need to compare is in the matrix.

Hi @zebra123 

 

Does all data come from the same table? Does the field in the slicer come from that table? Assume that all data is in the same table and that the expected result should be put in the same matrix, you can try below code to create a measure. Modify table and column names per your need. In my sample, "c" is the fixed one to be subtracted from. 

Difference = 
var _minuend = CALCULATE(AVERAGE('Table (2)'[Factor1]),ALLSELECTED('Table (2)'[Type]),'Table (2)'[Type] = "c")
var _subtrahend = AVERAGE('Table (2)'[Factor1])
return
_minuend - _subtrahend

vjingzhang_0-1658216457278.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

mariussve1
Solution Supplier
Solution Supplier

Hi,

 

Not sure if I understood you correct, but is this what you want?:

 

SUMX( 'Table', 'Table'[Column1] - 'Table'[Column2] )

 

Br

Marius

The data is in a matrix so I dont think that would work

But what you are talking about now is the visual? You show data in a matrix visual, or?

 

The table you having the data stored (fact table), how does that look like?

 

Marius 🙂

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.