Macros are an interesting part of Alteryx that falls under the program’s ‘Interface’ tool branch. They allow you to create customized tools that perform a specific analytic process repeatedly without the need for its’ replication and can be saved and used across multiple workflows. Macros also allow you to bundle a number of different actions and tools into the single tool. The creation process begins with an input data tool that contains the beginnings of the workflow to which you want your macro to work on. For a macro to work, the data files’ schema (meaning the order of the field names and their corresponding data types) must be the same wherever it’s used as the input, otherwise there will be an error. You also need to select the type of workflow to be the corresponding type of macro when crafting it, as shown below.


There are three different types of macros – Standard, Batch, and Iterative.


Standard Macros

These are the simplest types of macros found in Alteryx. Standard macros contain a workflow that completes a certain action and allows you to insert this into another workflow so you can easily and automatically complete a process that you may need to repeatedly run. The pictures below show a standard macro that inserts information on a person named Nick, the time that the macro was run to insert the fields into a workflow, and his tired rating. You can also see that the input data can either be inserted as text through the input data tool, or as an external file.


Batch Macros

Batch macros differ slightly from standard macros in that they process groups of data and run multiple times in a workflow, once for each record or selected groups of records. They also have an exception to the schema rule, in that the input data must still be the same but can have additional input columns without popping up with an error. The process still runs from the start to the end of the workflow, but it is based off what is inputted from a control parameter (you generally will type a question that will be answered when running the batch macro), which is paired with an Action tool to dictate the type of action that is run from the parameter.

Below is an example of how the batch macro is set up, which inserts into the input data what the day of the week is based off a specified date (NOTE: take care to select the correct Operand in the Action tool, depending on what format you want your field to return as).

Pictured below is how the batch macro looks like when inserted into a workflow (NOTE: The blue circle is only one of many ways you can customize what your macro looks like. You can make them different coloured circles, and even style them with as various images to make them look unique, which you can find in the interface designer tab as shown in the last of the 3 pictures below).


Iterative Macros

The final type of macro is the iterative macro, which is slightly different from the other macro types as it runs the process repeatedly until a certain specified condition is met. Essentially, it’s a loop that you can insert into a workflow to continuously do something until what you wanted done is completed. These functions are also useful in that they can be placed inside a batch macro, meaning they can be chained together for uses such as the creation of a number of columns until a certain amount have been created.

The example below utilizes the formula and filter tools looped back around to continuously rerun the macro if the condition in the filter tool is not met (or in this case, is met as it loops back out of the ‘true’ output). To allow for the output of the rows created in between the initial input data and the specified completion of the iterative macro, in this case the creation of rows that specify a date that is one day more than the previous date, an additional macro output tool is needed. The ‘O Output’ is the iterative output (selected in the interface designer which allows the continuous loop), the ‘R Output’ which outputs all the rows where the condition is not met, and the ‘D Output’ which outputs the row where the condition is met.

Pictured below is how said iterative function is used in a workflow, and we can see the macro has three different output points listed by the lettered abbreviation specified in the previous example; one for the iterative output, one for all the rows created where the condition hasn’t been met, and another output for once the condition has been met.


Nicholas Seah
Author: Nicholas Seah