Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Getting all sub-products associated with main products using recursion

scoetzer
5 - Atom

Hi there Alteryx community,

 

I hope you can help me: I have a multi-level Bill of Materials, with the main products, components, sub-components, sub-sub-components etc. listed. There can be many 'levels' in the chain of the product bill of material. Here is an example dataset: 

ProductMaterial
Product 1Component 1
Product 1Component 2
Product 1Component 3
Component 1Subcomponent 1
Component 1Subcomponent 2
Subcomponent 2Subsubcomponent 3
Product 2Component 4
Subsubcomponent 3

Subsubsubcomponent 4

 

I want to transform this table into a table where I can see for each main product (defined as: products at the beginning of the 'chain') what are all of the materials for each product. The output for this example should look something like this: 

 

ProductMaterial
Product 1Component 1
Product 1Subcomponent 1
Product 1Subcomponent 2
Product 1Subsubcomponent 3
Product 1Subsubsubcomponent 4
Product 1Component 2
Product 1Component 3
Product 2Component 4

 

 I suspect that potentially recursion would need to be used (as for each product we don't know up front how many 'levels' it would have), but I'm really banging my head trying to figure out how to achieve this.

 

Hoping that there will be some good suggestions from the community :) 

1 REPLY 1
Luke_C
17 - Castor
17 - Castor

Hi @scoetzer 

 

This weekly challenge might give you some ideas: https://community.alteryx.com/t5/Weekly-Challenge/Challenge-12-Creating-an-HR-Hierarchy/td-p/36740

It has a similar hierarchy concept.

 

Labels
Top Solution Authors