How to Create Alteryx Macros

Alteryx Macros give workflow developers a way to create a workflow once and re-use it many times by embedding into a larger workflow. Unlike Excel Macros, they require no coding, and only minimal knowledge above what they currently know about using Alteryx to deploy them.

Alteryx macros let you build and re-use workflows inside of other workflows. They come in multiple different types.

The best way to think about an Alteryx Macro is that they’re saved versions of workflows that can be embedded into a workflow, essentially creating a workflow within a workflow. In fact, some of the most common tools used in Alteryx are actually macros built by Alteryx themselves. We’ll explain what Macros are, the different types of macros, and how to create them.

Let’s jump in!

What are Alteryx Macros?

Alteryx Macros are a method for creating workflows and re-using them in other workflows. They’re similar to Excel Macros in that they record a set of pre-defined data transformation steps but differ in that they require no additional coding steps. Essentially a workflow is built, saved, and imported into another workflow as a single icon.

The example below shows the contents of a simple standard Alteryx Macro. It consists of 5 tools, a macro input, several data transformations, and a macro output tool. The workflow is saved a .yxmc file and then imported into a different workflow.

Example of a standard Alteryx macro embedded into a different workflow

After a macro is created, it is imported into a larger workflow. In the example above, we used the default circle icon for a macro which contains all of the tools above it. When working with macros, you can open them up and view all of the details by right clicking on them and choosing “Open Macro”.

By opening a macro, it’s similar to being able to drill into it to see all of the data transformation steps that are saved within that single icon.

Types of Alteryx Macros

There are three types of Macros in Alteryx, standard, batch, and iterative. Standard Macros are saved workflows that can be used inside of other workflows. Batch Macros accept an input and will run the same set of steps on each row of incoming data. Iterative Macros are less common and are used for what-if and goal seek analysis.

  • Standard Macro – A re-usable workflow, such as delimiting and formatting a complex .txt file that is used across a number of different processes. Create once and re-use many times.
  • Batch Macro – Runs the same set of steps based on rows of input data. The most common is importing a folder of files that have different formats. A directory tool feeds a list of file locations into the batch macro which applies many or no additional data transformations one file at a time then consolidates it.
  • Iterative Macro – Works like a goal seek function. Data goes into the macro, and the macro will run different iterations until a value is met. These are used to solve scenarios such as, how much money would you have in 10 years of an initial investment grew 7% a year. The macro will run 10 times and calculate the result of 7% compounding growth.

Standard and Batch Macros are by far the most common type of macro, with iterative being useful in niche cases but seldom used. From the workflow that contains a macro, you can identify the difference between a standard macro and a batch macro based on the upside down question mark of the incoming input anchor.

Icons for a standard and batch macro

Iterative macros look the same as Standard Macros when embedded into another workflow.

Creating a Simple Alteryx Macro

To create a macro in Alteryx, create a new blank workflow. Add a Macro Input Tool from the Interface Tool section. Build out your process as needed with regular data transformation tools. Then add a Macro Output Tool at the end of your workflow. Save the new workflow as a .yxmc file that can be imported into other workflows.

Step 1.) Add a Macro Input Tool

Start a new empty workflow, and add a Macro Input Tool to it. Configure the tool by referencing a file or a text input. Because the workflow is new and blank, Alteryx will need some kind of data to reference when configuring the subsequent tools.

In this step, column headers matter more than the actual data below it. When you attach the macro to a larger workflow it will use the data being input into the macro as the actual data that is transformed.

configuring an alteryx macro input tool

You can also start with a regular input tool, right-click and select “Convert To Macro Input” to automatically generate a macro input without having to further configure and re-select a file.

converting a standard data input tool into a macro input tool

The Macro Input and Macro Output Tools create the Input and Output Anchors of the final macro once embedded into a workflow. If you leave a Macro Output Tool off for example, your macro will have one input anchor and no output anchor.

Step 2.) Add Data Transformation Steps

This part will vary based on the goal you are trying to achieve. This is the part where you build your workflow based on what you want it to do. Just because it’s a macro doesn’t make it that special compared to a regular workflow. Drag and drop tools and build a workflow with the input data like you would with any other data.

example of a built out standard macro with input, data transformations, and output

Step 3.) Add a Macro Output Tool

One of the last steps to building a macro is adding a Macro Output Tool. This becomes the output node of the macro once completed. A Macro Output Tool isn’t strictly required either, there are some macros that run without outputting data into another part of the workflow.

It’s also possible to have multiple outputs for the same macro, the screenshot below shows a single macro with 3 output anchors inside of it.

example of an Alteryx macro with multiple outputs

Of course this isn’t strictly required when setting up a macro, but Alteryx gives you many different configuration options.

Step 4.) Save the Macro

When you finish creating a macro with the input, output, and other required data transformation tools save it like a normal workflow by going to File > Save. The one difference is that the file will save a .ymxc file instead of a regular .ymxd file. This is how Alteryx identifies it as a macro that can be embedded into other workflows.

Turning a Workflow into a Macro

As soon as a Macro Input or Macro Output Tool is added to an Alteryx Workflow, it will automatically be detected and change the workflow into a Macro File with a .yxmc extension. You can manually convert a workflow into a macro from the Workflow Configuration settings and adjust the Macro Dropdown box to select a macro type.

How to change an Alteryx Workflow into a macro or update the macro type of the workflow

When a control parameter is present, Alteryx will auto-detect a batch macro, but when setting up an iterative macro you will need to do so manually. It’s the one macro type that will not automatically be detected.

Adding Macros to an Alteryx Workflow

After a macro is saved, you can import it into another workflow by right-clicking on the canvas. Then select Insert > Macro and either select the macro that was recently saved or browse to select a pre-existing .ymxc file using Windows Explorer.

How to add an alteryx macro into another workflow by right-clicking the canvas

Macros that are recently saved will automatically show up in this list, making it easy to have multiple workflows open at one time. You can create a macro in one workflow and then go back to your regular workflow and it will be in the import macro list after saving it.

Using Macros with Alteryx Server

Macros must be present on Alteryx Server for them to run the same as they do in Alteryx Designer. Macros are normally packaged with other workflow assets when publishing from Designer to Server. However, if macros are saved on a local network drive the server will need access to the files and use the same file path.

One thing to be careful of is that when you save a Macro, it will automatically update when workflows containing that macro are opened. This means that every time you update a macro embedded into a larger workflow, you should consider re-publishing the workflow to server. This will ensure that the macro version you are using in desktop Designer matches the version published to the server.

Conclusion

Alteryx Macros are a great way to build a workflow once and re-use it many times. A number of companies keep repositories of macros for common tasks allowing users to leverage workflows that others have built to solve common business problems.

There are three primary types of Alteryx Macro, Standard, Batch and Iterative. Each one is designed to help you solve specific problems. They can take a little bit of work to set up initially, but once you do they can be re-used and embedded across many different workflows.

Scroll to Top