We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Flattening Org File

tearless75
6 - Meteoroid

Hi, I have a file looks like below

 

Column A  Column B

1                2

2                3

1                4

2                5

5                6

 

 

It should be converted into 

 

Column A  Column B  Column C  Column D

1                2                5                6

1                2                3

1                4

 

Challenging part is that I don't know how many columns I would need in the output since the input file is pretty large and do not know how many level there would be in the source. 

 

 

Can someone please help?

4 REPLIES 4
CailinS
Alteryx Alumni (Retired)

@tearless75 I can't imagine this is the only (or even best way) to do this, but I was able to solve with an Iterative Macro. I ran out of time to perfect my workflows so it may seem a little confusing. I've attached a Full Workflow - no iterative.yxzp (it contains a workflow saved as a .yxmc that isnt actually a macro, but does contain the macro I built). I've also included some screenshots so you can see how I first built out the iterative process manually to confirm my logic before taking part of the workflow and turning it into an iterative macro. 

workflow - macro - screenshot.jpg

In short, I needed to identify the first level of leader (1, in this case) and then use that as the first 'iterative' input for my macro + the original file as the 'look up' data (which stays the same throughout and doesn't iterate. Then I proceed to 'Join' on the employees of each manager iteration after iteration. I use a handy Iterative Macro feature, called the Iteration Number, to dynamically rename the manager levels as I continue through. The final employee does get renamed to Manager as again I ran out of time to perfect, but hopefully this shows you how it can be done.

Cailin Swingle
Customer Experience
Qiu
21 - Polaris
21 - Polaris
CailinS
Alteryx Alumni (Retired)

Great find, @Qiu I felt like I remembered something like it but didn't locate it (and I admit I wanted to dust off my iterative macro skills 😅)

Cailin Swingle
Customer Experience
Qiu
21 - Polaris
21 - Polaris

@CailinS 
Actually, its simply because I am bit lazy 😁
Good to practice the iterative macro skills.

Labels
Top Solution Authors