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

Multiply two columns from different tables, duplicates

Hi, for several weeks I started my adventure with powerbi. I have problem when I want to multiply two columns from different tables and do the sum.

Below are sample tables with the data:

 

pic1.JPG

 

 

 

 

 

 

 

 

 

First table is the table with bill of material items, second table is back order table.

I want to check how many BOM_items in Qty is missing in total multyplying by sum of Qty on each Main_Item from BackOrders table.

I try to use NATURALINNERJOIN but there is a problem, because my relation between those two tables can be only many to many, probably the reason are duplicates, but I can't delete duplicates, it comes direct from the postgresql database.

 

pic2.JPG

 

 

 

 

 

 

 

 

When I made new table using: BOM_Missing_Qty = NATURALINNERJOIN(BOM,BackOrders) , I have information:

 

pic3.JPG

 

Can someone help me or give me some suggestions.

 

Thanks, with best regards

Mariusz

2 ACCEPTED SOLUTIONS

Hi @mariusz2022 ,

 

I suggest you to create a calculated column in "BOM" Table.

Total Missing Qty = 
VAR _SUM = CALCULATE(SUM(BackOrders[Qty]))
RETURN
BOM[BOM_Qty] * _SUM

Result is as below.

RicoZhou_0-1652953726105.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

Perfect is working, thanks.

View solution in original post

4 REPLIES 4
vanessafvg
Super User
Super User

i am not quite sure what you are trying to do can you explain with an example of the actual result of what you are looking to do.

 

the  many to many relationship on your key will be creating this issue.   Your data sounds like it needs some additional modelling.

 

if you can explain in clearer terms what you are trying to do with an example and provide your expected result so its clear what you are wanting to come out with, also explaining how the different bom items under one main item needs to be handled.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Dear vanessafvg, there are two tables, BOM and BackOrders. 

In BOM table there are BOM_Item and BOM_Qty which are needed to produce  1pc of each BOM_Main_Item. In BackOrder table are Main_Items and Qty from sales orders which are missing now on the stock. I want to check how many Qty of each BOM_Item is missing.

For example:

In BOM table is Item1, which is produced from Profile1 (1pc) + Profile2 (1pc) +EPDM (6pcs) + Str1 (1pc) + Str2 (1pc)

In table BackOrders is the same Item1 5 times with quantities 15+30+100+43+125 = 313pcs

I want to check how many BOM_Items in Qty are missing, I need to count quantity from yellow column.

 

pic4.JPG

 

In above table do you see:

Profile1 - is missing: 313 pcs
Profile2 - is missing: 313 pcs
EPDM - is missing: 1878 pcs + 924 pcs = 2802 pcs in total
Str1 - is missing: 313 pcs + 308pcs = 621 pcs in total
Str2 - is missing: 313 pcs
Profile3 - is missing: 154 pcs
Profile4 - is missing: 154 pcs

 

I hope this is clear now.

 

Thanks

Mariusz

Hi @mariusz2022 ,

 

I suggest you to create a calculated column in "BOM" Table.

Total Missing Qty = 
VAR _SUM = CALCULATE(SUM(BackOrders[Qty]))
RETURN
BOM[BOM_Qty] * _SUM

Result is as below.

RicoZhou_0-1652953726105.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Perfect is working, thanks.

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.