Alteryx Designer Desktop Discussions

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

Problems determining levels in hierarchy with iterative macro

heh
5 - Atom

Hi all,

 

I've stumbled across a problem when I'm trying to designate levels on a quite simple organizational hierarchy. 

 

The hierarchy looks roughly like this - complete example in the files included.

 

Unique IdentifierNameReports ToLevel
0Employee_0 
3Employee_30 
8Employee_80 
9Employee_90 
11Employee_110 
13Employee_130 
14Employee_140 
147Employee_1473 
148Employee_1483 
149Employee_1493 

 

I want to determine the level of all the employees from the top (Employee_0) - like this: 

 

Unique IdentifierNameReports ToLevel
0Employee_00
3Employee_301
8Employee_801
9Employee_901
11Employee_1101
13Employee_1301
14Employee_1401
147Employee_14732
148Employee_14832
149Employee_14932

 

I think the problem I'm facing is that I need to be able to determine the correct level for Employee_0 in iteration 1 and then somehow deliver it back to the input for iteration 2 in order to correctly set the level for Level 1 employees.

 

alteryx iterative example.png

 

Any ideas on how to solve this problem would of course be greatly appreciated as I can't see to wrap my head around it. 

 

Thanks,

Hans Erik

3 REPLIES 3
kat
12 - Quasar

Hi @heh

 

Take a look at this. It was a weekly challenge that dealt with the same problem and should help you along.

 

Cheers

Katrin

jdunkerley79
ACE Emeritus
ACE Emeritus

I attach a quick attempt.

 

The trick I sue is to send the all the data round and round and stop only when no new rows are added to hierarchy or all are assigned.

 

I do this by counting records and then using a filter to determine whether or not to loop.

heh
5 - Atom

Thanks @jdunkerley79 for an elegent solution. And thanks @kat for pointing me in the direction of one of the useful articles so I actually get a little bit better grasp on the iterative macros. 

 

I really appreciate it guys.

 

All the best,

Hans Erik

Labels