Iterative Macros

by Tara Robinson

This is the second part to my mini series of macros. For this section I will be looking at iterative macros. I will also be creating this as an example in Alteryx.

What is an Iterative Macro?

If you think of the iterative output as a loop- ie it will keep going until it meets the condition to stop. This can be demonstrated by the animation below.

Example

So below is what we wished to create it shows the starter sheet then what the macro should look like.

So lets get started. So first lets copy the input and place into a workflow. Now we are going to change this input into a macro input. Before we continue further if we go to the configuration window and press workflow we can change this macro to an iterative.

Now we have done that I am just going to save that. Now to continue I am going to add a formula and create a new column for this which is going to be savings with interest rate added to this. For this example I am going to use 0.05 and I am going to see how many months it takes before Barry reaches £2000 in his savings.

Now we can also add a filter which says savings is equal or greater then 2000 afterwards.

As we can see this is currently false as it does not exceed 2000. Now we can add a macro output to both true and false of the filter. I am also going to add a formula tool of the true anchor so that I can see how many iterations it took before it reached this. Tip iterations start from 0 so add 1 to formula to see actual number of iterations.

Don't forget to save. Now that we have created the macro. We need to change the names of our outputs to make it easier for when we configure. The iterative one is always false in the filter. I like to place the iterative macro near the input so we can see that loop. To configure press view interface designer. Then press the properties toggle and change the input to the input and then the iteration to the iteration output- hence why naming helps. For Now everything else can remain the same.

Once again save this and add this back to our starter data and connect to the browse tools.

We should now see that it took 6 months for Barry to hit 2000.

Mon 13 Feb 2023

9 mins read

Thu 26 Jan 2023

Fri 27 Jan 2023

3 mins read

Thu 26 Jan 2023