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
Child | Parent |
A | B |
B | C |
C | D |
E | B |
F | Z |
Z | H |
I would like to add columns containing the hierarchy for each element, and its oldest ancestor:
Child | Parent | Path | Ancestor |
A | B | /D/C/B/A | D |
B | C | /D/C/B | D |
C | D | /D/C | D |
E | B | /D/C/B/E | D |
F | Z | /H/Z/F | H |
Z | H | /H/Z | H |
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.