Forum Discussion

paulfink's avatar
paulfink
Icon for Post Patron rankPost Patron
6 years ago

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

    • paulfink's avatar
      paulfink
      Icon for Post Patron rankPost Patron

      hi amitchandak,

       

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

       
       
       
       

       

      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.

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    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? 

  • 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!

    • Anonymous's avatar
      Anonymous
      Not applicable

      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.