December 20, 2023

Understanding Macros in Alteryx

By João Leite

Alteryx is a powerful data analytics tool that enables users to blend, prep, and analyze data in a streamlined and efficient way. One of the key features of Alteryx is macros, which allow users to automate repetitive tasks and streamline their workflows.

In this blog, we will discuss macros in Alteryx, specifically which types of macros are available, and tips on how to study and use macros effectively.

What Is A Macro In Alteryx?

In Alteryx, a macro is a collection of tools and workflows that can be reused across multiple workflows. Macros allow users to create customized tools tailored to their specific needs. Macros can be used to automate repetitive tasks, create reusable workflows, and improve the efficiency of your data analytics projects.

The types of macros available in Alteryx Designer Workflow configuration

Types Of Macros In Alteryx

There are four types of macros in Alteryx:

Standard Macros
Standard macros are used to package data analytics processes that require multiple tools and workflows. For example, you could use a standard macro to package a complex regression analysis or a custom report format.

Batch Macros
Batch macros perform the same series of actions on multiple inputs. For example, you could use a batch macro to standardize the format of multiple Excel files or perform the same data-cleaning steps on multiple datasets. This type of macro requires a control parameter as an input.

Iterative Macros
Iterative macros perform a series of actions repeatedly until a certain condition is met. For example, you could use an iterative macro to perform a Monte Carlo simulation or iterate through multiple data sources to find a specific value.

Location Optimizer Macro
This type of macro is also an iterative one; it can be used in spatial analysis to identify an optimal location(s). For example, you could use this type of macro to optimize the distance between a supplier and a buyer.

Alteryx also allows you to convert parts of your workflow to a macro. It is a faster way to make macros, but there are some restrictions like:

  • You must be using Alteryx 2022.1 or later.

  • You need to run the workflow first and browse everywhere data is available.

  • You need to save the workflow before converting to a macro.

  • The selected tools need to be in a continuous path and connected to each other (Comments, Explorer Boxes, and Tool Containers are exempt from this).

  • The selected tools must not contain errors.

  • The selected tools must not contain any In-DB tools.

  • The selected tools must not be connected to any action tools.

  • The selected tools must not contain a Python tool.

  • The selected tools must not include data that contains Spatial data types, BLOB data types, or Report data types.

When To Use Each Macro Type

Standard macros are best suited to package repetitive parts of your workflow or to allow the reuse of common steps on several different workflows. Differently from the others, this type of macro will execute only once. 

Let’s say for example you want to check if a phone list contains correctly formatted phone numbers; you could use regular tools to do this process, convert them to a macro, and then apply this macro to every input you have that has a phone number.

Example of creating a macro from 3 steps in a standard workflow

Batch macros are best suited for repetitive tasks requiring the same actions to be performed on multiple inputs. The control parameters used in Batch Macros can also be used as conditions to perform specific steps depending on their value.

An excellent use of Batch macros is controlling containers from a control parameter variable. For example, you can have a Boolean control the activation of an upper or lower part of a workflow inside a macro. This is done by setting the action to Update Value with Formula and adding a [Destination] = [#1] Formula on the upper one, and [Destination] != [#1] on the lower one.

Iterative macros are very similar to for statements in programming languages; if you need to iterate your data until a condition is met, they’ll be the most suited type of macro for you. This post shows an example of using iterative macros to assign items from warehouse stock to retail stores based on the store’s priority.

Note that on Iterative macros, you’ll end up using a formula with the [Engine.IterationNumber] variable, this will check for how many times the workflow already ran and will be used at the stop condition.

Location Optimizer macros are used for spatial analysis. If you need to optimize a report about the distance between points or about the best locations to use to affect most clients, this will be the best-suited macro type for you. Alteryx Designer has two good examples on Help > Sample Workflows > Using scripting and automation tools > Build a macro.

Tips For Studying Macros In Alteryx

To get started with macros in Alteryx, follow these tips:

Understand The Basics
Start by understanding the basics of macros in Alteryx. Learn how to create a basic macro and how to use it in a workflow. Macro tools are in the Interface category. This help document can show you the steps required to build one.

Practice With Sample Workflows
Alteryx offers a range of sample workflows that include macros. Use these sample workflows to practice understanding, creating, and using macros.

Learn From The Alteryx Community
Join the Alteryx Community to connect with other users and learn from their experiences. The Alteryx Community is an excellent resource for learning about everything related to Designer and other Alteryx features.

Take Advantage Of Alteryx Training Resources
Alteryx offers a range of training resources, including eLearning courses, webinars, and certification prep courses. Take advantage of these resources to deepen your knowledge of Alteryx and macros.

Check The Weekly Challenges
Alteryx weekly challenges on the community has some macro usages. Search for “Macro” on the community post and give them a try.

Conclusion

Macros in Alteryx are a powerful tool for automating repetitive tasks, creating reusable workflows, and improving the efficiency of your data analytics projects. Understanding the types of macros available and when to use them can help you maximize this feature. Follow the tips outlined in this blog to study and use macros effectively in your Alteryx projects.

Need help getting started with macros in Alteryx?

phData’s team of experts is here to assist!

Data Coach is our premium analytics training program with one-on-one coaching from renowned experts.

Accelerate and automate your data projects with the phData Toolkit