Alteryx Designer Desktop Discussions

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

My iterator macro keeps adding columns in join or append,

mithily
8 - Asteroid

A simple iterator macro that looksup alphabets and returns a number from 1-26. However it keeps adding columns to the output.

I feed in 

A
B
C

and  want to see

A 1

B 2

C 3 

in two columns however I get many many columns.

I am attaching macro and workflow,

Please help me move past this

7 REPLIES 7
grazitti_sapna
17 - Castor

Hi @mithily , I have fixed the issue now the result looks like this

grazitti_sapna_0-1599807446788.png

 

This is how I resolved it.You were filtering on the basis where iterator>=26 so that is why it was running in the loop multiple times. I have changed it to iterator<=26 and applied a select tool to deselect the iterator field to get the desired result.

grazitti_sapna_1-1599807468186.png

 

Therefore it is working fine now.I hope it helped.

 

Thanks.

 

 

Sapna Gupta
mithily
8 - Asteroid

@grazitti_sapna Sapna thank you, it is working but I thought since I am looking at 26 in the list, I have to run the lookup 26 times, Why is the condition <=26? I thought the iterator ends when it is false and the true is the output we should look at.

Can you explain it further. I really appreciate you help and did not expect such a quick reply?

grazitti_sapna
17 - Castor

Hi @mithily , the value of your iterator is 1 therefor if you use the condition iterator>=26 it will always output your result in false condition therefore running the iterations for 26 times whereas if you use this condition that is iterator<=26 it will always be true. Hence no iteration will be run.

Let me illustrate it with an example when using condition iterator >=26 the result will be

 

grazitti_sapna_0-1599810866863.png

grazitti_sapna_2-1599810950353.png

 

When you run the macro with condition iterator<=26

grazitti_sapna_3-1599811014805.png

grazitti_sapna_4-1599811025571.png

 

I hope this helps.

Thanks.

 

Sapna Gupta
Ben_H
11 - Bolide

Hi @mithily,

 

I don't really understand the point of this as a macro.

 

Even the working version that @grazitti_sapna has provided you with doesn't really iterate as it doesn't need to.

 

You've effectively got a single join within an iterative macro that will never need to loop more than once.

 

Am I missing something here?

 

Regards,

 

Ben

mithily
8 - Asteroid

@Ben_H  you are correct, I did not need an iterative macro. I am trying to understand how to create iterative macros and struggling to come up with a small real world case to use iterative macro. If you have a small real world example, please share it with me so I can learn. 

Ben_H
11 - Bolide

HI @mithily 

 

Some of the weekly challenges are a good way into iterative macros.

 

Here are a couple of examples -

 

https://community.alteryx.com/t5/Weekly-Challenge/Challenge-135-Locker-Problem/td-p/307345

 

https://community.alteryx.com/t5/Weekly-Challenge/Challenge-12-Creating-an-HR-Hierarchy/td-p/36740

 

The good thing here is that you have a set challenge, with the solution you are aiming for. If you get stuck you can also have a look at other users solutions to get an idea of how they work.

 

There is a good iterative macro problem that I think is one of the questions on the Core accreditation (maybe?) It gives you a list of airports arrivals and departures. Your job is to chain them together to work out what the nth leg of the journey is.

 

Regards,

 

Ben

mithily
8 - Asteroid

@Ben_H  ty, very much, I will look through those examples and learn it, I apprecaite you pointing me to the correct challenge.

Labels