Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Iterative macro for nested hierachy

gerbaudo
7 - Meteor

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.

 

4 REPLIES 4
WayneWooldridge
Alteryx Alumni (Retired)

Hi @gerbaudo,

I think I understand where you are going with this.  I had to restructure this a bit; take a look at the attached workflow.  What I did is think of your 'Child' field as people.  Each of these people has a parent.  The attached workflow will iterate through all the child/parent relationships to establish a genealogy line.

 

Pay close attention to macro itself.  You'll need to modify some settings in the macro using the View --> Interface Designer screen (click on the wrench on the left side of the window).  Specifically, you need to select your iteration input and iteration output fields. 

 

 

gerbaudo
7 - Meteor

Thank you so much @WayneW !

It works like a charm.

 

Best,

 

Davide

rakhibubbly86
5 - Atom

Is there any way to put filter where I can specify like I want all childrens of Parent ID 4 so i can get 1,2,3

rcruz03
5 - Atom

Hello,

I tried the sample and getting the results below. 

ChildParentAncestorPath
CDDD:C
ZHHH:Z
BCCC:B
CDDD:C
ZHHH:Z
FZZZ:F
ABBB:A
EBBB:E
BCCC:B
CDDD:C
ZHHH:Z
FZZZ:F

 

Why am I not showing the expected the results below. 

ChildParentPath
ABC:B:A
EBC:B:E
BCD:C:B
FZH:Z:F
Labels