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
Solved! Go to Solution.
Hi @mithily , I have fixed the issue now the result looks like this
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.
Therefore it is working fine now.I hope it helped.
Thanks.
@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?
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
When you run the macro with condition iterator<=26
I hope this helps.
Thanks.
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
@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.
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
@Ben_H ty, very much, I will look through those examples and learn it, I apprecaite you pointing me to the correct challenge.