Appending data based on custom requirement using Power Query formula

RajaR

New Member
Joined
Aug 29, 2020
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Dears,
I've a custom requirement for product Bill of material (BOM) creation. I've two tables of data (Table1 - Base data & Table2 - Level2 BOM).
I need output as per Table3 - Required Format.

All 3images I've uploaded in using XL2BB add-in.

Also I've very little knowledge in Power query. Attached are sample files, wherein in actual I've to work with 20k rows of data for both Table1 & 2.
Hence while replying kindly share bit of explanation (will help me to understand).

Thanks in advance.
Regards,
Raja

Table1
Table 1 - Base Data
FG#FG DescriptionLevel1 CodeLevel1 DescriptionLevel1 QtyLevel2 codeLevel2 Desc
3SAA100001R1Product 101A2SAA111110R1Basic CB13SAR0000001A901Basic CB 101A
3SAA100001R1Product 101A2SAA111111R1Frontal13SAR0000002A901Frontal 101A
3SAA100001R1Product 101A2SAA111112R1KIT 2pcs13SAR0000003A901KIT 2pcs 101A
3SAA100001R1Product 101A2SAA111112R1KIT 2pcs13SAR0000003A901KIT 2pcs 101A


Table2
Table 2 - Level2 BOM
LevelLevel2 BOMLevel2 BOM DescQty
23SAR0000001A901Basic CB 101A1
3RP000001Screw2
33SAR0011001LONG SCREW5
33SAR0011002SIGNALLING R1
43SAR0022001SIGNALLING R11
33SAR0011003SIGNALLING L1
42SAR1111101811SIGNALLING L11
5RU2341Shaft1
5RP9021Spring2
5QP10001810Lever Assy
6AA1234Moving1
6AA1235Screw1
23SAR0000002A901Frontal 101A1
3RA00001801Label assy1
4RY56789Counter1
4RR1234Plate1
23SAR0000003A901KIT 2pcs 101A1
3XX123Kit 2A1
3YY1234Cap1
4RR3452Fixture3


Table3
Table 3 - Required Output
FG#FG DescriptionLevelCodeDescriptionQtyRemarks
3SAA100001R1Product 101A12SAA111110R1Basic CB1Level1 Code From C2
3SAA100001R1Product 101A23SAR0000001A901Basic CB 101A1Level2 Code From F2
3SAA100001R1Product 101A3RP000001Screw2From Level2 BOM table
3SAA100001R1Product 101A33SAR0011001LONG SCREW5""
3SAA100001R1Product 101A33SAR0011002SIGNALLING R1""
3SAA100001R1Product 101A43SAR0022001SIGNALLING R11""
3SAA100001R1Product 101A33SAR0011003SIGNALLING L1""
3SAA100001R1Product 101A42SAR1111101811SIGNALLING L11""
3SAA100001R1Product 101A5RU2341Shaft1""
3SAA100001R1Product 101A5RP9021Spring2""
3SAA100001R1Product 101A5QP10001810Lever Assy""
3SAA100001R1Product 101A6AA1234Moving1""
3SAA100001R1Product 101A6AA1235Screw1""
3SAA100001R1Product 101A12SAA111111R1FrontalLevel1 Code From C3
3SAA100001R1Product 101A23SAR0000002A901Frontal 101ALevel2 Code From F3
3SAA100001R1Product 101A23SAR0000002A901Frontal 101A1From Level2 BOM table
3SAA100001R1Product 101A3RA00001801Label assy1""
3SAA100001R1Product 101A4RY56789Counter1""
3SAA100001R1Product 101A4RR1234Plate1""
3SAA100001R1Product 101A12SAA111112R1KIT 2pcs1Level1 Code From C4
3SAA100001R1Product 101A23SAR0000003A901KIT 2pcs 101A1Level2 Code From F4
3SAA100001R1Product 101A23SAR0000003A901KIT 2pcs 101A1From Level2 BOM table
3SAA100001R1Product 101A3XX123Kit 2A1""
3SAA100001R1Product 101A3YY1234Cap1""
3SAA100001R1Product 101A4RR3452Fixture3""
3SAA100001R1Product 101A12SAA111112R1KIT 2pcs1Level1 Code From C5
3SAA100001R1Product 101A23SAR0000003A901KIT 2pcs 101A1Level2 Code From F5
3SAA100001R1Product 101A23SAR0000003A901KIT 2pcs 101A1From Level2 BOM table
3SAA100001R1Product 101A3XX123Kit 2A1""
3SAA100001R1Product 101A3YY1234Cap1""
3SAA100001R1Product 101A4RR3452Fixture3""
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Please try

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Level2BOM"]}[Content],
    Renamed = Table.RenameColumns(Source,{{"Level2 BOM", "Code"}, {"Level2 BOM Desc", "Description"}}),
    AddL2 = Table.AddColumn(Renamed, "L2", each if [Level] =2 then [Code] else null),
    L2 = Table.FillDown(AddL2,{"L2"}),
    MergedL2 = Table.NestedJoin(Excel.CurrentWorkbook(){[Name="BaseData"]}[Content], {"Level2 code"}, L2, {"L2"}, "Base", JoinKind.LeftOuter),
    Renamed2 = Table.RenameColumns(MergedL2,{{"Level1 Code", "Code"}, {"Level1 Description", "Description"}, {"Level1 Qty", "Qty"}}),
    AddedL1L2 = Table.AddColumn(Renamed2, "Custom", each Table.Combine({Table.AddColumn(Table.FromRecords({_}),"Level", each 1),[Base]})  ),
    RemovedColumns = Table.RemoveColumns(AddedL1L2,{"Code", "Description", "Qty", "Level2 code", "Level2 Desc", "Base"}),
    ExpandedCustom = Table.ExpandTableColumn(RemovedColumns, "Custom", {"Level","Code", "Description", "Qty"})
in
    ExpandedCustom

FG#FG DescriptionLevelCodeDescriptionQty
3SAA100001R1Product 101A12SAA111110R1Basic CB1
3SAA100001R1Product 101A23SAR0000001A901Basic CB 101A1
3SAA100001R1Product 101A3RP000001Screw2
3SAA100001R1Product 101A33SAR0011001LONG SCREW5
3SAA100001R1Product 101A33SAR0011002SIGNALLING R1
3SAA100001R1Product 101A43SAR0022001SIGNALLING R11
3SAA100001R1Product 101A33SAR0011003SIGNALLING L1
3SAA100001R1Product 101A42SAR1111101811SIGNALLING L11
3SAA100001R1Product 101A5RU2341Shaft1
3SAA100001R1Product 101A5RP9021Spring2
3SAA100001R1Product 101A5QP10001810Lever Assy
3SAA100001R1Product 101A6AA1234Moving1
3SAA100001R1Product 101A6AA1235Screw1
3SAA100001R1Product 101A12SAA111111R1Frontal1
3SAA100001R1Product 101A23SAR0000002A901Frontal 101A1
3SAA100001R1Product 101A3RA00001801Label assy1
3SAA100001R1Product 101A4RY56789Counter1
3SAA100001R1Product 101A4RR1234Plate1
3SAA100001R1Product 101A12SAA111112R1KIT 2pcs1
3SAA100001R1Product 101A23SAR0000003A901KIT 2pcs 101A1
3SAA100001R1Product 101A3XX123Kit 2A1
3SAA100001R1Product 101A3YY1234Cap1
3SAA100001R1Product 101A4RR3452Fixture3
3SAA100001R1Product 101A12SAA111112R1KIT 2pcs1
3SAA100001R1Product 101A23SAR0000003A901KIT 2pcs 101A1
3SAA100001R1Product 101A3XX123Kit 2A1
3SAA100001R1Product 101A3YY1234Cap1
3SAA100001R1Product 101A4RR3452Fixture3
 
Upvote 0
That's awesome!!!.... ? Thanks a lot....
I will try for bulk data & revert for any issues.....

Once again thanks guy's......
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,678
Members
449,248
Latest member
wayneho98

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