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
Oleander
Helper I
Helper I

Aggregating the sum and Unit from a list of Parent item and a corresponding BOM list

I am doing a budget follow-up and want to sum up all the parts included in our part list A and the corresponding BOM list.

Model1 - Model3 are complete models with parts 1 - 17 included, but in some cases there are some parts with subParts in a BOM and in these cases I want that part as 0 and that I want to add the units from the BOM list instead in the summation.

Any help is appreciated

 

List A

ModelPartUMNo
Model11pcs2
Model12pcs5
Model13pcs1
Model14pcs3
Model15pcs5
Model16pcs3
Model17pcs1
Model18pcs4
Model19pcs5
Model110pcs1
Model111pcs3
Model112pcs3
Model113pcs3
Model114pcs5
Model115pcs1
Model116pcs2
Model117pcs3
Model21pcs3
Model22pcs4
Model23pcs1
Model24pcs4
Model25pcs1
Model26pcs1
Model27pcs1
Model28pcs1
Model29pcs1
Model210pcs3
Model211pcs4
Model212pcs3
Model213pcs1
Model214pcs2
Model215pcs5
Model216pcs2
Model217pcs4

 

BOM list :

Part  SubPartUMNo
4201kg1,2
4202kg0,87
4203mt0,3
4204mt0,2
4205pcs1
4206pcs1
5203mt0,3
5204mt0,6
5205pcs4
5206pcs1
6204mt0,8
6205pcs4
6206pcs6


And I want the result of the connected lists to be like this :

Summery Table

Summan av No Model  
PartUMModel1Model2Total Sum
1pcs2,03,05,0
2pcs5,04,09,0
3pcs1,01,02,0
4pcs0,00,00,0
5pcs0,00,00,0
6pcs0,00,00,0
7pcs1,01,02,0
8pcs4,01,05,0
9pcs5,01,06,0
10pcs1,03,04,0
11pcs3,04,07,0
12pcs3,03,06,0
13pcs3,01,04,0
14pcs5,02,07,0
15pcs1,05,06,0
16pcs2,02,04,0
17pcs3,04,07,0
201kg3,64,88,4
202kg2,63,56,1
203mt2,41,53,9
204mt6,02,28,2
205pcs35,012,047,0
206pcs26,011,037,0

 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

 

let
Source = Table.NestedJoin(Table_A, {"Part"}, Table_BOM, {"Part"}, "Table_BOM", JoinKind.Inner),
Expand = Table.ExpandTableColumn(Source, "Table_BOM", {"SubPart", "UM", "No"}, {"SubPart", "UM.BOM", "No.BOM"}),
#"Replaced Value" = Table.ReplaceValue(Expand,each [No],0,Replacer.ReplaceValue,{"No"}),
#"Removed Other Columns" = Table.SelectColumns(#"Replaced Value",{"Model", "Part", "UM", "No"}),
#"Inserted Multiplication" = Table.AddColumn(Expand, "No.BOM2", each [No.BOM] * [No], type number),
#"Removed Other Columns1" = Table.SelectColumns(#"Inserted Multiplication",{"Model", "SubPart", "UM.BOM", "No.BOM2"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns1",{{"UM.BOM", "UM"}, {"No.BOM2", "No"}, {"SubPart", "Part"}}),
Custom1 = Table.NestedJoin(Table_A, {"Part"}, Table_BOM, {"Part"}, "Table_BOM", JoinKind.LeftAnti),
#"Removed Columns1" = Table.RemoveColumns(Custom1,{"Table_BOM"}),
Custom2 = Table.Combine({ #"Removed Columns1", #"Removed Other Columns", #"Renamed Columns"}),
#"Pivoted Column" = Table.Pivot(Custom2, List.Distinct(Custom2[Model]), "Model", "No", List.Sum)
in
#"Pivoted Column"

 

Stéphane 

View solution in original post

5 REPLIES 5
Oleander
Helper I
Helper I

Hi,

I have a foloowup question about this BOM Calculation :

I have now a list i Power Pivot that I want to check if I'm missing any pricing from the Price list that is a Lookup lsit to this BOM;
How should I go about to get the "X" in the column "Cost Driven" , as mandetory pricecheck from the Price-lookup database ?

It's only the child that is allowed to have a price.

 

PathParentCompAmountUnitCost Driven
111 EA 
1|12311231EA 
1|123|1245112451EAX
1|123|8005180051,2KGX
1|313637071313637071EA 
1|31363707|8005180050,3KGX
1|314779001314779008EAX
1|31832613183261EA 
1|318326|156781156781EAX
1|318326|516881111516881111EA 
1|318326|51688111|613636881613636881EAX
1|318326|51688111|0023912391,06KGX
1|318326|31814913181491EA 
1|318326|318149|613637021613637021EA 
1|318326|318149|61363702|753639751753639751EAX
1|318326|318149|61363702|913489111913489116EAX
1|318326|318149|61363702|50022315002231,4KGX
1|318326|318149|61363702|50022415002242,6KGX
1|318326|318149|886885371886885371EAX
1|318326|318149|503958251503958250,4KGX
1|318326|318149|504247391504247390,8KGX
1|11911511191154EAX

Hi @Oleander, you can achieve this in Power Query.

 

Result

dufoq3_1-1714743498173.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZMxcsQgDEWvknFNISEJiTJFJkWOsLM34fDRZkHGTMimwNaD/2Uh8O124JFivPn4eD/uyacbZhpLEc2LPlhCEeFFYgBjfoQp+/Prs4sIqZCCdtGCkWvM/5IQEl0TsmoFiISBdk1olEuIJlgkDaWojW1O8aoTLGaIo5UL7tStPHbmcdctuLUBZKpd1KME5dqIH4e/kOu50RPW3M/FZ0EKeS7oxBempuJB1XFGC75yVyS2Gk2bsPzDLd6UuKknJN62ZfHy7H1ATvuWNjM/C6FxVxfcFCtAVSxLfCkQ/qpTgDNrnPiEkGy2IXq/4q8cwL2g+zc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Path = _t, Parent = _t, Comp = _t, Amount = _t, Unit = _t]),
    Paths = List.Buffer(Source[Path]),
    Ad_CostDriven = Table.AddColumn(Source, "Cost Driven", each if List.Contains(Paths, [Path] & "|", (x,y)=> Text.StartsWith(x,y)) then null else "X", type text)
in
    Ad_CostDriven

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

I wonder if I could use this formula without getting dublicates if the formula is picking up the component number in the Parent column for another Parent part ?

Check=

VAR _SEL = SELECTCOLUMNS(BOM;"NP";PATHITEMREVERSE(BOM[Path];2))

Return

IF(BOM[Comp]<>PATHITEM(BOM[Path];1);IF(BOM[Comp] IN _SEL;BLANK();"X");BLANK())

 

Appreciate any help from the community

//Göran

Oleander
Helper I
Helper I

HI Stéphane,

Thank you for you support. It worked and I'm so grateful for your solution.

//Göran

slorin
Super User
Super User

Hi,

 

let
Source = Table.NestedJoin(Table_A, {"Part"}, Table_BOM, {"Part"}, "Table_BOM", JoinKind.Inner),
Expand = Table.ExpandTableColumn(Source, "Table_BOM", {"SubPart", "UM", "No"}, {"SubPart", "UM.BOM", "No.BOM"}),
#"Replaced Value" = Table.ReplaceValue(Expand,each [No],0,Replacer.ReplaceValue,{"No"}),
#"Removed Other Columns" = Table.SelectColumns(#"Replaced Value",{"Model", "Part", "UM", "No"}),
#"Inserted Multiplication" = Table.AddColumn(Expand, "No.BOM2", each [No.BOM] * [No], type number),
#"Removed Other Columns1" = Table.SelectColumns(#"Inserted Multiplication",{"Model", "SubPart", "UM.BOM", "No.BOM2"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns1",{{"UM.BOM", "UM"}, {"No.BOM2", "No"}, {"SubPart", "Part"}}),
Custom1 = Table.NestedJoin(Table_A, {"Part"}, Table_BOM, {"Part"}, "Table_BOM", JoinKind.LeftAnti),
#"Removed Columns1" = Table.RemoveColumns(Custom1,{"Table_BOM"}),
Custom2 = Table.Combine({ #"Removed Columns1", #"Removed Other Columns", #"Renamed Columns"}),
#"Pivoted Column" = Table.Pivot(Custom2, List.Distinct(Custom2[Model]), "Model", "No", List.Sum)
in
#"Pivoted Column"

 

Stéphane 

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.

Top Solution Authors
Top Kudoed Authors