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
paulfink
Post Patron
Post Patron

Subtracting Columns from 2 Tables

Hi guys,

 

i need help with DAX as im trying to subtract two columns in two different tables but they each have columns with the same names which i need so that i can have a total.

 

What i am trying to do is to subtract Column A (Amount) from Column B (Time) but having Column C ( Names) as the overall factor that will total up A and B so that each name in C has a total subtracted amount.

 

E.g 60 (Amount) - 1.0 (Time ( 1.0 is in 10 different rows)) = 50 for a name in C

 

 

Thank you for helping.

5 REPLIES 5
paulfink
Post Patron
Post Patron

hi guys,

 

its okay now, no need to help.

 

it somehow fixed itself.

 

the A-B did not work it only showed the subtracted on each row so no change but i made a new visual and put in names->subtracted-> amount -> time -> etc. and it worked. So thank you for your help!

Hi Paulfink

 

That is because of the difference between a column and a measure in PowerBI. The measure you created will be calculated dynamically - so when you added Column C to a visual it will then perform your calculation (A - B) split by column C, although the underlying data doesn't change.

Bizualisation
Resolver I
Resolver I

Assuming you have a relationship between the two columns simply make a measure like 

Measure = [Column A] - [Column B]

Now if you build a visualisation, say a table, and put in Column C as your rows and your measure as your value, PowerBI will return the subtracted value for each item in Column C

 

Does that answer your question? 

amitchandak
Super User
Super User

First Aggregate then you be able to

Like Sum(table1[A]) - Sum(Table2[A])

 

But the information you have provided is not making the problem clear to me. Can you please explain with an example. If possible please share a sample pbix file after removing sensitive information.
Thanks.

My Recent Blog -

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

hi amitchandak,

 

here is a dummy Excel file i put together to show my situation

 
 
 
 

image.png

 

on the left is an example of the data i have, the right is what is should look like in power bi.

 

This is probably a simple A - B formula but on my power bi it is subtracting it per row instead of totally the subtracted amount.

 

thank you.

 

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.