Forum Discussion

PreetiSahu321's avatar
6 years ago

Subtract two columns from different table using DAX in power bi

Hello Power BI Community Members,

 

Recently, I was working with Power BI DAX. As per my requirement, I have to subtract two different columns of values from two different tables. Let me explain to you properly so that you can understand easily.

 

I have one table named: "Orders". This Orders table has one column as "Sales doc." whose data type is the Whole number. Similarly, I have another table named: "Sales" and this has another column as "Order" whose data type is the Whole number.

 

As per my requirement, I have to subtract the values from the Sales doc. (from Orders table) to Order (from the Sales table). As I am new to Power BI, I don't have any idea to subtract from different tables using DAX. Please, can anyone suggest to me what I have to do?

 

Thanks in Advance!!!

2 Replies

  • Nathaniel_C's avatar
    Nathaniel_C
    Icon for Community Champion rankCommunity Champion

    Hi PreetiSahu321 
    If I understand your issue, try this.

    Subtract measure = SUM(Orders[Sales Doc])-Sum(Sales[Order])

     


    Let me know if you have any questions.

    If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
    Nathaniel

    • PreetiSahu321's avatar
      PreetiSahu321
      Icon for Helper I rankHelper I

      Hi Nathaniel_C ,

       

      I have applied the formula and it is giving me the exact value. But one more thing I want to know is, there is one common column in both Orders and Sales tables i.e. BillDate (Date and Time Datatype). As per my requirement, I want to subtract the measure per monthly basis. Let me explain to you properly.

       

      You can see below are two tables as Orders and Sales. I want to subtract the values from Net value to Sales US$ of the current month. As this is November month is going on, So it will subtract the values for the current month only. i.e. (132454-370.80=132,083.2)

       

       

      Can you suggest me if anything I have to do else?