When developing in Alteryx, there are many instances where a particular subset of the workflow is used over and over again. Rather than placing the same set of tools after each other repeatedly, it is useful to take advantage of macros.

 

What are Macros?

A macro is a workflow that can be saved and called upon the way a tool would. This allows for a simpler, less cluttered and iterable workflow. Depending on its design, a macro may have any or no anchors, and may require user input. Many default tools in Alteryx began as macros, such as Data Cleansing and Select Records, as indicated by the small plus symbol to the bottom right of the tool icon. Macros exist as .yxmc files.

 

How to Create Macros

Creating a macro in Alteryx is straightforward. Follow this simple example to see how easy it is:

1. Create a workflow that processes some target input data that matches the input that will be fed into the macro.

2. Right-click on the input data and click Convert to Macro Input.

3. Drag a Macro Output tool from the Interface pane above and connect to the output anchor of the final tool.

4. In the Configuration pane click Workflow and confirm that Alteryx has automatically classified the type as Macro.

 

5. Save the workflow as the suggested .yxmc file.

 

Now that we have saved the macro, we are able to use it in a separate workflow. To call on a macro, right-click on the canvas and click Insert, then click Macro. If the macro workflow is open in Alteryx, the macro will appear; otherwise, click Browse… and find it in your hard drive.

 

Types of Macros

Standard macros

Standard macros are workflow processes that can be packaged up and saved as an individual tool to be used in a new workflow.

Batch macros

Batch macros are workflow processes that take a set of records as an input and runs the workflow once per record input. This input is called a control parameter and is represented by a ¿ input anchor.

Iterative macros

Iterative macros are workflow processes that feed a designated output back into the workflow as an input to run continually until there is no more designated output or until the maximum number of iterations is reached.

To set up an iterative macro, select Iterative Macro in the Workflow Configuration pane.

Now, in the Properties of the Interface Designer pane, select an Iteration Output that will feed the workflow’s remaining output into the workflow again, and an Iteration Input macro input that will determine where this iterated output is fed into.

 

The best way to familiarise oneself with macros is to practice using them. The Alteryx Weekly Challenges provide a great wealth of problems to solve with macros. Give them a go and see how quickly you improve. Happy developing!

Image by Square Frog from Pixabay

Hunter Iceton
Author: Hunter Iceton

Hunter Iceton is an enthusiastic and positive individual. He graduated from Sydney Uni in 2017 with a Bachelor of Commerce (Liberal Studies) majoring in Finance, Marketing and Quantitative Business Analytics. For the next few years, Hunter spent his time creating and releasing music, while tutoring primary and high school students in Mathematics and Business Studies. Hunter is now excited to be joining The Data School, looking forward to approaching analytics with a creative perspective. In his spare time, Hunter enjoys continuing to create music, reading philosophy and cooking plant-based dishes. Otherwise, he can usually be found at a restaurant, a bar or an art gallery.