Alteryx Macros Part 1: The Standard Macro

by George Pattinson

What is a Macro?

In Alteryx, a macro is in essence just a workflow that can be inserted into another workflow, in the form of a single tool. There are many reasons you may want to create a macro because it allows for a laborious or repetitive process to be packaged up into one tool. For example, if you are wanting to calculate the number of years it would take for an initial investment to double you could build those calculations into a macro; the Data Cleansing tool in Alteryx is actually a fairly complicated macro which can remove or replace certain data from your target field. To read more about how macros work, head over to the Alteryx documentation page here: https://help.alteryx.com/20212/designer/macros.

Data Cleansing macro: the inner workings of the tool

What sets macros apart from a normal workflow is the use of various interface tools. These are shown in the image below. Dragging a macro input tool into your workflow will automatically update the workflow configuration into a macro type. Subsequent tools used in the workflow should now display a lightning bolt, and sometimes also a 'Q' symbol above.

The Interface tools in Alteryx

The Standard Macro

The rest of this blog is about creating a very simple macro which can transform a field of data into a column of smileys. This is to demonstrate how to set up a standard macro and go through some of the configuration settings for the interface tools. More generally, standard macro use cases for involve packaging up specific parts of your workflow to reuse elsewhere, such as simple data parsing processes.

Step 1

There are a couple of ways to create a macro. Possibly the most intuitive is to first drag a Text Input tool onto your canvas, writing in one value of data into Field1 and then right clicking -> Convert To Macro Input:

This will automatically update the canvas configuration into a Macro type.

Step 2

Create the workflow by adding a Formula tool which updates Field1 with a ":)" smiley. From the Interface tools, then drag on a Drop Down tool and connect the Q onto the lightning bolt symbol above the Formula tool. An Action tool will then appear in this connection:

You can learn more about what the different types of Q, lightning bolt and black diamond anchors mean here: https://help.alteryx.com/20212/designer/action-tool

Step 3

Time to configure the Drop Down and Action tools: first give the Drop Down tool some text which will be displayed when the macro is being used - here I have used "Choose a smiley face from the list:".

Next using the List Values drop down, select 'Manually set values'. This is the easiest way to input new values to be displayed in your macro. In the Properties pane, write in a few different types of smileys to give the user some choice - one per line.

Configuration for the Drop Down tool

Now for the nifty bit: in the Action tool configuration, select the part of the Formula tool field you would like to update with values in the Drop Down tool. In this case, just leave the "@expression - value=":)" highlighted in blue.

Note: if the output from the Formula tool is just a colon (not the full smiley), you will need to add a Select tool between the Macro Input and Formula tool to adjust the size of the string field to above 1 to allow for more characters to be parsed into Field1.

Step 4

Add a Macro Output tool to the workflow and save to a folder which is easy to find. I saved mine to a folder called Macros which can then be found in the top banner in Alteryx. In a new workflow, test out your macro by adding it to an input data tool. In the configuration pane of the macro, you will be able to select which type of smiley output you would like to add into the data.

Step 5

To add one last element of interactivity so that the user can select which field in their data they would like to change into smileys, go back into the macro and add a Select tool between the Formula and Output tools. Add an Action tool to the Select tool and choose 'Update Select with Reverse Field Map'. Then connect this Action tool with the Macro Input tool, making sure to tick the 'Show Field Map' option.

The complete 'smiley' macro

Now your macro is complete! Save it and add it to a workflow - you should be able to now choose a different type of smiley to update a data field of your choice.

Of course this is highly unlikely to ever be used in real scenario, however it does cover the basics of how to set up a standard macro.