Alteryx Designer Desktop Discussions

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

Iterative macro to increment filter tool

al_sweets
8 - Asteroid

I have a simple workflow that reads in a Text input which is then read into a Filter tool which is currently setup as [Control]=1 which then streams off TRUE records to go through the main processing in the workflow.

 

I then want it to run again but this time with the Filter tool set to [Control]=2. It needs to iterate this workflow, incrementing this Filter tool each time, where it's final run would be [Control]=40.

 

Any idea how I can do this? I haven't seen any examples of incrementing an integer number within a Filter tool.

4 REPLIES 4
Thableaus
17 - Castor
17 - Castor

Hi @al_sweets 

 

Yes, you're right, you could use either Iterative Macro or Batch Macro.

 

With Iterative Macro:

You need to setup the macro with an Input and two Outputs - One is a Loop Output (which will feed the next iteration Input) and a Final Output which is going to be your dataset with all results from each iteration.

 

In the Filter tool, you could setup as [Control] = Engine.IterationNumber + 1, as it starts from 0.

 

With Batch Macro:

You would have a list with parameters from 1 to 40, and in the macro you would set the control parameter to update the Filter Tool (specifically the [control] number). Then you need only a macro input and output (this output will be unioned to each iteration with the result)

 

If you give an example of your workflow I can even quickly do it for you.

 

Cheers,

al_sweets
8 - Asteroid

Hi @Thableaus,

 

Unfortunately I can't share the workflow.

 

The problem is that this workflow contains another macro which is where my main processing occurs - I know nested macros can sometimes be bad practice but I am unable to change this process. So my workflow has an input, Filters the [Control] variable and reads it into my other macro. There are no outputs inside this workflow that I want to iterate - the records are simply read into another macro where my processing occurs. 

 

This means I don't know how I can loop the output since there are technically no outputs within this workflow that I want to iterate.

afv2688
16 - Nebula
16 - Nebula

Hi @al_sweets ,

 

If I am understanding you well (not really sure about that), you want to iterate the control variable and input it into another macro to be read? then why don't you just chain the two macros?

 

I mean: Input->Iterative macro -> Your processing macro

 

This should work for you.

 

Can't really do much without some getting clear what you want to do, sorry

 

Thableaus
17 - Castor
17 - Castor

@al_sweets 

 

That said, a batch macro could be most appropriate for your case.

 

Here's an example:

 

- Batch Macro

 

BatchMacroConfig.PNG

 

It's very simple. The control parameter updates the Filter Tool (specifically the Control Number).

There's an input (which is the input of your workflow) and each iteration the dataset with control number specified goes to your nested macro. 

That said, if you have 40 control numbers, the nested macro will be run 40 times.

Make sure you configure your Macro Input with the fields you use in the workflow, this is very important.

 

Workflow:

 

capture.PNG

 

 

Your input could be anything, I used a text input as an example.

The important thing here is to use a Unique Tool to separate a list of unique [Control] numbers that will feed the Control Parameter and iterate through the Batch Macro.

 

This is a basic setup to give you some ideas. As you see, it doesn't matter if you have a nested macro, as long as you understand the concept of a Batch Macro, you are free to use it in many possible situations.

 

I appended my example in version 2018.4 if you'd like to take a look at it.

 

Cheers,

 

Labels