Quantcast
Channel: Data Preparation & Blending discussions
Viewing all articles
Browse latest Browse all 4999

Iterative macro for nested hierachy

$
0
0

Hello,

 

   I am trying to implement an iterative macro to build a nested hierarchy from a list of entries.

For example, starting from an input

 

ChildParent
AB
BC
CD
EB
FZ
ZH

I would like to add columns containing the hierarchy for each element, and its oldest ancestor:

 

ChildParentPathAncestor
AB/D/C/B/AD
BC/D/C/BD
CD/D/CD
EB/D/C/B/ED
FZ/H/Z/FH
ZH/H/ZH

I have tried to follow the example in the "Creating a HR hierarchy" post,

but I cannot get the output I'd like.

In particular, I have defined an iterative macro with the output for the next iteration ('N')

and connected it to the input for the next iteration ('S'), but I see that after two iterations

I have multiple outputs (some duplicated), and the "Path" is two-level deep at most.

The two files (macro and workflow) are attached here.

I implemented a recursive function in python that behaves as expected,

but I cannot wrap my head around the Alteryx implementation with an

iterative macro--I must be missing something basic, sorry about this.

Any advice on what I am doing wrong, please?

 

Thank you.

 


Viewing all articles
Browse latest Browse all 4999

Trending Articles