Making macros accessible in Alteryx 2 – Batch Macro

This is the second post in a series aimed at making the three types of macros in Alteryx accessible to anyone: standard macro (see it here), batch macro and iterative macro.

This post will cover:

  • Batch macro:
    1. Explanation
    2. Uses
    3. The obscure Control Parameter

Batch Macro

Put it simply, a batch macro is a regular macro that will run multiple times, each using something different as input. One could also see it as a “For loop” in Alteryx:

For each item run the macro and combine all the results

Uses

Whenever you want to run a macro (when and why?) but you have multiple inputs that you want to process. Maybe there are multiple URLs that need to be fed to an API. Or multiple files to be processed (maybe with different schemas). Or multiple employees to be analyzed within a macro. For all those cases, the batch macro is the solution, but the secret sauce is the…

Control Parameter

The key controller of the batch macro. Without it, you have just a regular macro. Add the control parameter and it will update whatever value within the macro to run it as many times as inputs available.

For example:

This workflow will go through a list of ID and perform a series of operations based on a match with a provided ID.

It can easily be updated to a standard macro by changing the input/outputs.

Alteryx Macro Workflow

And then upgraded to a batch macro by including a control parameter that will update the ID I am checking against.

Alteryx Batch Macro

Once saved, it can be inserted into another workflow, but it will throw an error until the control parameter is properly mapped.

Control Parameter not mapped throws error

In this example, I do not have just one ID, but many. And I want to run the Alteryx macro once for each ID present in my list. How? Just connecting my list of IDs to the macro query anchor (¿) and going to the configuration window and selecting the correct field to map in the “questions” tab.

Configuration of the Control Parameter

Mapping the Control Parameter to the Field to update in each iteration

 

After running the macro, the output will be combined in a single table (union) and all iterations will have the same schema (this is the default setting, but can be modified in the Interface Designer > Properties tab)

Interface Designer properties

Interface Designer Properties for the Batch Macro

 

Have a look at one example of a well documented batch macro combined into an Analytic App by Marc Reid 

Any comments, please leave them here or reach me at @dsmd4vid.

Author:
David Sánchez
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab