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
Anonymous
Not applicable

Subtracting from columns in different tables

Hello Community, 

 

Trying to subract different columns from different tables and having no luck.   Have tried various formulas and nothing seems to work.   The resulting sum (total and at the row level) is a gigantic number that makes no sense.  

 

I need to subract "Potential" in the Merge1 table, from "Net Price" in the Sales Orders table.      There is no direct relationship between the tables, but I guess both are indirectly connected thru the Date Table, and thru the Customers Table  (Customer ID).

 

Est Close date on the Merge1 table is connected to Dates in the Date Table.       Due Date on the Sales_Orders is also connect to Dates.        Customer ID is connect to the same named fields in each table.     All filtering and cross filtering works.  

 

There is not a one-to-one match between the rows on the tables.  In other words I am not subtracting  Row1 from one table and Row 2 from another table.   There are a lot more rows in the Sales_Orders tables then there are in the Merge1 table.  

 

I just simply need to subtract the sum of Potential from the sum of Net Price in whatever filter context is selected.   For example, filtering on January should give me the total Potential for January, and the total potential for Net Price   (it does this perfectly now).  What I need is a the correct formula to subtract those two things regardless of filter context   (so with or without out a filter applied).    Thanks in advance for any help!

 

model.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Greg_Deckler Thanks Greg. It actually turned out to be a lot simpler. I fixed a relationship and rewrote two simple SUMX formulas.

SumX Potential - SUMX(Merge1,Merge1[Potential]) (and is equivalent to net price)
Then he subtracted them using this.

SumX deviation ([Net Price SumX]-[SumX Potential])
This seems to work well, even if I apply filters (date filter for example)

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

So in general this is going to involve something like:

  • RELATED
  • RELATEDTABLE
  • LOOKUPVALUE
  • MAX(FILTER(...)...)

 

One of those. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

LeoReyes79_0-1620146017430.png

Hello as I can do in power bi q I take the balance cell and add the must and I subtract the having so I have my accumulated in power bi idem to print q pass, in excel I have it as well..

Anonymous
Not applicable

@Greg_Deckler Thanks Greg. It actually turned out to be a lot simpler. I fixed a relationship and rewrote two simple SUMX formulas.

SumX Potential - SUMX(Merge1,Merge1[Potential]) (and is equivalent to net price)
Then he subtracted them using this.

SumX deviation ([Net Price SumX]-[SumX Potential])
This seems to work well, even if I apply filters (date filter for example)

@Anonymous 

 

By the way, you may help accept solution. Your contribution is highly appreciated.

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Glad you got it @Anonymous ! Things definitely tend to work better when you have a solid data model!! 🙂

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.