What is a Macro?
A Macro is a group of tools that are grouped together into a single tool. In Alteryx there a 4 types of macros:
- Standard Macro: runs only once – used when the exact same process is repeated
- Batch Macro: repeats the process for each incoming field into the control parameter – used when the user knows how many times they need to run the workflow
- Iterative Macro: repeats the process until a certain condition is met ( output into input until a certain condition is met)
- Analytic App
When to use a Macro?
Macros are used when a certain process needs to be done in Alteryx repeatedly and would take much time if you constantly reconstruct the process yourself.
In this blog post I will take you through how to build a Standard Macro.
You have been using Macros
If you drag Count tool or Data Cleansing tool into the canvas you will find a plus sign in the bottom right of the tool. Right click the tool and select open macro:cleanse.yxmx. Here is what is happening behind the data cleansing tool in the background:
Basically, if you find a plus sign in the bottom right of a tool that means it is a macro. If you can’t find the plus sign, go to options > user settings > edit user settings > canvas and in the bottom left check the box that says: Display Macro Indicators on Tools.
Building a Standard Macro:
Let’s say you work at a company and you receive a dataset every day with a list of companies and their respective details and your task is to filter the dataset every time you receive it. That’s when you would need to use a macro to perform the same process again and again.
Here’s a snapshot of our dataset I will be using:
To start off, we will place a filter tool onto the canvas and we will configure the filter tool so that the company name equals to PowerLine Money (doesn’t really matter which company to pick).
I will also drag another filter tool to filter on the Closed_At and Created_At and will custom the filter so that Created_At<= “any date” AND Closed_At>”same any date”.
Macro Input Tool
There are 3 ways to create a Standard Macro:
- Click on the white space in the canvas and in the canvas configuration pane select workflow tab and from there you change the workflow type from standard workflow to Macro
- Drag the macro input tool onto the canvas
- My preferred method is to right click the input tool and select convert into Macro.
Macro Output Tool:
A Macro needs an input and an output to process in and out the data. Go to interface tab and drag macro output into the canvas.
Now we have the macro almost ready, but we want to give the user the option to configure the macro the way they desire and change the company name and range of dates.
Drop Down Tool:
In the interface tab , drag Drop Down onto the canvas and connect it to the filter tool. Make sure every time you drag a Drop Down to connect it to the lighting bolt.
In the configuration pane of the Drop Down we will select Manually set values and enter company names we would like to give the user the option to choose from.
If you noticed, the Action Tool automatically appeared when you connected the Drop Down tool to the filter tool. Action Tool acts as the interface between Drop Down Tool and any other connected tool. When you click an action type, you will get different options on how the action tool would perform, in our case we will choose Update Value (Default) and below we will select simple and then operand value and save your Macro (make sure to name your macro so that you can easily find it)
Open a new workflow and insert the input tool. Right click on the canvas and select insert > Macro > choose your macro and run your workflow
Now your Macro should be working and also your user have the option to choose what exactly they want to look at.
Here is a training introduction to building macro video if you wish to practice building standard macros: https://community.alteryx.com/t5/Live-Training/Live-Training-Introduction-to-Building-Macros/td-p/139730