Find Parents Quantity

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,342
Office Version
  1. 365
Platform
  1. Windows
FYSA: These are parts that are listed in a drawing to show how something is assembled

I have Six columns of data [Index], [Level], [Make/Buy],[Assembly], [Material] and [Quantity]

1​
1Make1000614-2011000614-201
1​
2​
2Buy1000614-20100005300
1​
3​
2Buy1000614-2016455062
1​
4​
2Make1000614-2016456677
2​
5​
3Make64566776456678
1​
6​
4Buy64566786456678-B
1​
7​
3Buy64566776456676
1​
8​
3Buy645667700026614
1​
9​
3Buy64566771033030-001
1​
10​
2Buy1000614-2016456679
1​
11​
2Buy1000614-2016456683
1​
12​
2Buy1000614-2016456688
1​
13​
2Buy1000614-20130-07-131
1​
14​
2Buy1000614-2011033940-001
2​
15​
2Buy1000614-201B0612-2-041
1​
16​
2Buy1000614-2018000632
1​
17​
2Buy1000614-2018000813-006
7​
18​
2Buy1000614-2018000811-001
4​
19​
2Buy1000614-201B0612-2-014
1​
20​
2Buy1000614-2018000767-003
1​
21​
2Buy1000614-201NAS620C5
2​
22​
2Buy1000614-201M12133/5-1P
1​
23​
2Buy1000614-201MS90707-4012
1​
24​
2Buy1000614-201NAS620C5L
2​

I want to, some how in Power Query, get a new column that had what's called the Unit Qty. To get this the formula /steps need to look as each rows parent (or next level up) and multiply its ext quantity by the rows Quantity. So the results would look like this (Which I did manually)


INDEXLEVELMAKE/BUYASSEMBLYMATERIALQUANTITYUNTI QUANTITY
1​
1Make1000614-2011000614-201
2​
2​
2​
2Buy1000614-20100005300
1​
2​
3​
2Buy1000614-2016455062
1​
2​
4​
2Make1000614-2016456677
2​
4​
5​
3Make64566776456678
1​
2​
I am multuplied by my Parents Unit Quantity
6​
4Buy64566786456678-B
1​
2​
7​
3Buy64566776456676
1​
2​
8​
3Buy645667700026614
1​
2​
9​
3Buy64566771033030-001
1​
2​
10​
2Buy1000614-2016456679
1​
2​
11​
2Buy1000614-2016456683
1​
2​
12​
2Buy1000614-2016456688
1​
2​
13​
2Buy1000614-20130-07-131
1​
2​
14​
2Buy1000614-2011033940-001
2​
4​
15​
2Buy1000614-201B0612-2-041
1​
2​
16​
2Buy1000614-2018000632
1​
2​
17​
2Buy1000614-2018000813-006
7​
14​
18​
2Buy1000614-2018000811-001
4​
8​
19​
2Buy1000614-201B0612-2-014
1​
2​
20​
2Buy1000614-2018000767-003
1​
2​
21​
2Buy1000614-201NAS620C5
2​
4​
22​
2Buy1000614-201M12133/5-1P
1​
2​
23​
2Buy1000614-201MS90707-4012
1​
2​
24​
2Buy1000614-201NAS620C5L
2​
4​


I hope that make sense. I am trying to do this as efficiently as possible. (Again in Power Query)

Thank You
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
In your example the Unit Quantity is always just two times Quantity. If that's the case then there's not much to it (although I suspect that is not the case).
 
Upvote 0
I must not have explained it well. No its not always x 2. For each row, the "Parent" is identified in the Assembly field. Example MATERIAL item 8000811-001 shows its parent (aka Assembly) as 1000614-201. 1000614-201 has a QUANTITY of 2 (it will not always have a value of 2). In this case , to calculate the the field quantity I need to take the QUANTITY of 8000811-001 and multiply it by the Parent's (1000614-201) Unit Quantity.


What I did, as a temporary fix was to create a duplicate of the table. in that new table I created a column and named it "Parent Quantity" and made it equal to the rows QUANTITY. I then created another column and named it "Parents Level". Here I took the rows LEVEL value and subtracted 1. (Each rows direct Parent will always have a level value of one less - think of it as a Family tree if that helps any)

I then merged the two tables.

= Table.NestedJoin(#"Changed Type1", {"Assembly", "EndItem"}, #"BOM Get Parent's Qty", {"Material", "EndItem"}, "BOM Get Parent's Qty", JoinKind.LeftOuter)
 
Upvote 0
Change Source in three places to the correct step name.

Power Query:
= Table.AddColumn(Source, "Unit Quantity", each Number.From([Quantity])*Number.From(Source[Quantity]{List.PositionOf(Source[Material],[Assembly])}))
 
Upvote 0
Solution
That worked perfectly. Very much appreciated.

Is there a way to find its parent [Make/Buy]? I would love to get rid of the merges.

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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