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
monktrain
Frequent Visitor

Add column to table from another table where there is a many to many relationship

I have a Sales Order Lines table and a Forecast table.  There is a Part Category column in the Sales Order Lines table that I need in the Forecast table so I can show a forecast by Part Category.  There is a many-to-many relationship with the part numbers because the same part number may be on many sales order lines, and the part number is also forecast for several different months.  I have tried various versions of LookupValue, NATURALLEFTOUTERJOIN and FILTER and I just can't seem to get there.  Can anyone help?  Here is a basic layout of my tables:

LookupValues.jpg

I have also tried to calculate the sum of the forecasted amount (no shown) in a measure, with no success. This is my measure for that:

Category Monthly Goal = sumx(filter(Forecast,Forecast[ForecastStartDate]=date(2020,3,1) && MAX(SalesOrderLines[Category]) = "Wheel"),[ForecastedAmount])
That does not throw up an error, but I do not get a value.
 
Thanks,
David
5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @monktrain 

What is your measure [ForecastedAmount]?

Which tables does the measure use?

 

Best Regards

Maggie

Sorry, the [ForecastedAmount] is actually in the Forecast table.  I forgot to put that in there. 

Thank you.

Hi @monktrain 

Add [amount] from "forecast table" to the table visual, it would sum the [amount] based on the column [Category].

What's wrong?

What is the expected result do you like?

Capture5.JPG

Best Regards

Maggie

Mariusz
Community Champion
Community Champion

Hi @monktrain 

 

You can use a budget pattern for your scenario, as per below.
https://www.daxpatterns.com/budget-patterns/

 

Also, it's considered as a best practice to avoid many to many, so you can create Product Table and join both tables on 1:*

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Thank you.  I will check this out.  

 

I would love to avoid the many-to-many relationship.  Unfotunately, this information is coming from an ERP system where I cannot change the data entities.  

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.