ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now
The Alteryx Community will be temporarily unavailable for a time due to scheduled maintenance on Thursday, April 22nd. Please plan accordingly.

Alteryx Designer Discussions

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

Macro to build hierarchy levels based on parent child relationship

bobby-wan-kenobi
5 - Atom

Hi All -

 

Getting stuck trying to build hierarchy levels for account data.  Here is an example of what I want the outcome to me.  The level is what I am after.  The root (level 1) always has a null for parentid in the dataset.  Was attempting an iterative macro but I am struggling.

 

IdParentIdlevel
1 1
212
312
412
512
623
723
834
934
1034
1145
1245
1345
1445
1545
danilang
17 - Castor
17 - Castor

Hi @bobby-wan-kenobi

 

You'll have to supply a sample of what your input data looks like.  Without that, we don't know where to start. It's like trying to force-lift a X-wing, without first learning how to do a hand stand:)

 

Your current workflow and macro would help too.  That way we could focus on fixing what's wrong with your solution instead of inventing a new one for you.

 

Dan

bobby-wan-kenobi
5 - Atom

@danilang Sorry about that!  The input data are the 2 left columns.  Id and Parent Id.  Below is the example.  I am attaching an example of how I do this manually.  The problem with this is I would need to build out for every new level.  I want it to be dynamic.

 

IdParentId
1 
21
31
41
51
62
72
83
93
103
114
124
134
144
154
 
 
mbarone
15 - Aurora
15 - Aurora

Try the "Tile" tool under Preparation.

 

Config as:

Tile Method = Unique Value

Unique Fields = ParentID

Everything else as is.

 

That should do it.  No macro needed.

bcampbell0621
8 - Asteroid

Hi!

 

After I ran the first tile statement all of the people in my list have been grouped by their supervisors.  Which is great!   Do the supervisors need to be grouped again by their supervisors, or is that already complete.  Sorry for the silly question; I am just trying to get my head around a recursive process for my data.  

 

Data looks like this:

 

Unique ID

Fist name

Last name

Supervisor Unique ID

 

The only time the Unique ID would match the Supervisor ID would be in the case of the CEO. 

 

 

fpinchon
8 - Asteroid
Zack1
5 - Atom

This worked so well! Thanks a million... sometime the ultimate sophistication is simplicity!

Labels