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 loop

maverick_70
7 - Meteor

Hello,

 

I have a some what of a tricky workflow that I need help with.

I have a table which have the following information: It has 4 columns Part 1, Part2, Part1(m/b) and Part2(M/B).

 

Part1Part2Part1(M/B)Part2(M/B)
ABCa1234MB
ABCb4321MB
CDEa8989MM
CDEa4344MB
CDEa3434MB
EFGa3131MM
EFGa9999MM
a3131a7979MB
HIJa6464BM
KLMa8765BB
a8989a6767MM
a6767a8787MB
a9999a5454MB
NMOa8967MM

 

I am trying to build a table which would look like this.

PartResult
ABCa1234,b4321
CDEa8787,a4344,a3434
EFGa7979,a5454
a3131a7979
HIJHIJ
KLMKLM
a8989a8787
a6767a8787
a9999a5454
NMOa8967

 

The conditions I am using are

 

if Part1(M/B) = M and Part2(M/B) = B then Part2

if part1(M/B) = M and Part2(M/B) = M then look the value of part2 in the Part 1 column and again check for the conditions if part1(M/B) = M and part2(M/B) = M then check the value in part2 column in column 1 and check for the conditions again if part1(M/B)= M and part2(M/B) = B then part2

 

I am going down each level until Part2 M/B = B or if there is no part 2 in part1 column. The purpose is to go down at the deepest possible level.

 

The table with the result column is what I am looking for.

 

Your help would be greatly appreciated.

16 REPLIES 16
AbhilashR
15 - Aurora
15 - Aurora

Nice one @grossal

grossal
15 - Aurora
15 - Aurora

I have adapted it @maverick_70. Give it a try.

 

We might stumble across another issue, but I am ready to fix everything that occurs. It's hard to prepare a workflow for all possible things when the sample data is limited. I hope it works without another fix, but we have to find out 😃

 

Let me know if it worked.

 

Best

Alex

grossal
15 - Aurora
15 - Aurora

Thanks!

 

I already had you in mind when typing "I am sorry, I think I have to use Python here, but XXX and XXX mind find an Alteryx-way".

 

These problems are kinda tricky in Alteryx (at least for me). It's much easier in Python or in this case, in Haskell. I am glad I found an Alteryx way, but I am still not really happy the way we have to do these things.

 

How would you do this?

maverick_70
7 - Meteor

Hi Alex,

 

Found some issues:

Part1Part2Part1(M/B)Part2(M/B)New Column
ABCa1234MBa1234
ABCb4321MBb4321
ABCexampleMMexample(should be 'abc')
CDEa3434MBa3434
CDEa4344MBa4344
CDEa8989MMa8989(should be a8787)
EFGa3131MMa3131(should be a7979)
EFGa9999MMa9999(should be a5454)
HIJa6464BMHIJ
KLMa8765BBKLM
NMOa8967MMa8967
a3131a7979MBa7979
a6767a8787MBa8787
a8989a6767MMa6767(should be a8787)
a9999a5454MBa5454
exampleabcMBabc

 

i have added some comments in the new column.

grossal
15 - Aurora
15 - Aurora

The logic was already working right, but I messed it up to clean the output right, therefore the Join in the main workflow made mismatches and the results looked wrong. Sorry that I missed that.

 

I have added a part in the end to make it easier to check if it works on a bigger sample.

 

grossal_0-1588333359675.png

 

grossal_1-1588333372453.png

 

An updated version is attached.

 

Best

Alex

 

 

maverick_70
7 - Meteor

Brilliant! I will test it with my dateset and will reach out if anything comes up!

Thanks again Alex!

Ben_H
11 - Bolide

Hi @maverick_70

 

I know this is already solved but I needed some practice with Iteration!

 

My solution is probably fairly similar to the existing one but here it is anyway.

 

I contained the logic within the Macro - The macro works out the correct output (I think) and only outputs recordID and the output value, I then just join onto the original list to get the original values + output.

WorkflowImage.png

The iteration list reads in and applies the logic you specified, anything with a simple output gets sent straight to the output stream. Records that require further work are then joined to the second input which is just the full data set.

 

Any that join - I keep the left record ID and the rest of the data from the right input and send to iterate again.

Those that do not join (left) Just take the part2 value and get sent to output.

 

MacroImage.png

 

I *think* this works. 

Labels