How to create relation in different table

ismailRajiwate

New Member
Joined
Feb 8, 2016
Messages
3
Hello Expert.
Need your expert advice to extract the output based on three tables.
The sample("SampleA100.png") data is attached to this message.

1st Table is the List of Finished Product and it Qty produced.
2nd Table has the Recipe for each Finished Product. The ingredients list contain some semi-Finished products whose ING_ITeM code starts with "2-"
3rd Table has the Recipe for Semi-Finished Products.

By using the above information how I can get the output to show total consumption as shown in the "Required output" Table.
Kindly advise me, what are the best way and how I can achieve it.
Let me know if you need further details.

Thanking you in anticipations.
Ismail
 

Attachments

  • Sample100A.png
    Sample100A.png
    49.3 KB · Views: 4

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,

Load your tables into power query and left join them correctly.
Your M query in advanced editor should look something like this:
Power Query:
let
    Source = Table.NestedJoin(Production_List, {"FINISHED_PROD_CODE"}, Finished_Product_Receipe_List, {"FINISHED_PROD_CODE"}, "Finished_Product_Receipe_List", JoinKind.LeftOuter),
    #"Expanded Finished_Product_Receipe_List" = Table.ExpandTableColumn(Source, "Finished_Product_Receipe_List", {"ING_ITEM", "QTY"}, {"ING_ITEM", "QTY.1"}),
    #"Merged Queries" = Table.NestedJoin(#"Expanded Finished_Product_Receipe_List", {"ING_ITEM"}, Semi_Finished_Product_Recipe_List, {"SF_RECEIP_CODE"}, "Semi_Finished_Product_Recipe_List", JoinKind.LeftOuter),
    #"Expanded Semi_Finished_Product_Recipe_List1" = Table.ExpandTableColumn(#"Merged Queries", "Semi_Finished_Product_Recipe_List", {"SF_RECEIP_CODE", "ING_ITEM", "QTY"}, {"SF_RECEIP_CODE", "ING_ITEM.1", "QTY.2"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Semi_Finished_Product_Recipe_List1", "Total", each if [SF_RECEIP_CODE] is null 
then Value.Multiply([QTY],[QTY.1])
else Value.Multiply([QTY], Value.Multiply([QTY.1],[QTY.2]))),
    #"Sorted Rows" = Table.Sort(#"Added Custom",{{"FINISHED_PROD_CODE", Order.Ascending}, {"ING_ITEM", Order.Ascending}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Sorted Rows",{{"Total", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"QTY.1", "QTY.2"})
in
    #"Removed Columns"
 
Upvote 0

Forum statistics

Threads
1,217,364
Messages
6,136,113
Members
449,993
Latest member
Sphere2215

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top