Using macros in Alteryx can sound intimidating, especially if you’re relatively new to Alteryx, however, along your Alteryx journey you may find that you need certain types of macros in order to complete specific tasks. Aside from the fact that macros are occasionally necessary, they can also save you a lot of time or present an alternate solution to challenges. In this blog I’m going to tell you about the first of the four different types of macros, Standard Macros, and show you how you can use them and when you should use them. But first lets discuss what a macro is and what the use cases for them are.
What is a Macro?
In general, macros are a means to compress a workflow into a single tool, which we can then use in other workflows. In simpler terms macros are workflows which you can save as a tool and reuse so you don’t have to keep building the same workflow over and over again. You might be more familiar with macros than you think! There are already many macros built into Alteryx for your convenience, the below screenshots show how you can check “Display macro indicators on tools” in order to see which tools are inbuilt macros.
Once you have checked this box and applied the changes you’ll be able to see a white plus symbol in a black square in the bottom right of each tool that is a macro, like this:
Using the Count Records tool as an example, we can then open it up and see what’s happening inside by right clicking on the macro and selecting “Open Macro”:
Inside it looks like this:
As you probably already know; you can use the Count Records tool just like any other tool, have data flow into it and it outputs a result – any Standard macro you create will follow the exact same logic! Hopefully this gives you a general idea of what a macro is, now lets do a bit more of a deep dive.
Standard Macros
So before we go into the components of a Standard macro and how to build one, why should we use them? There are three main reasons why you should use a Standard macro:
- Save a lot of time by reusing previously built workflows in future workflows
- Share processes easily with other people
- Standardising processes
Now you know why and when you should use a Standard macro, lets have a look at how to build one (it’s simple I promise!). In order to successfully create a Standard macro you need two things: a Macro Input tool and a Macro Out tool. The macro workflow itself will go in between these two tools; so in truth there are three components to a Standard macro: the Macro Input, the actual workflow and the Macro Output.
Macro Input
Let’s have a look at Macro Inputs first. This is where data will enter your macro (i.e. the start of your macro workflow). You can insert the Macro Input tool in a variety of ways, either:
Click on the “Interface” tab and drag in the Macro Input tool.
Search “macro input” in the top right search bar.
Or right click on a Text Input tool or Input Data tool and select “Convert to Macro Input”.
I recommend starting with either a Text Input tool or Input Data tool and then converting it into a Macro Input tool when you are ready to save the workflow as a macro. This way you can build out the macro with data resembling what you want coming into the macro. Now that we know how to start a macro, lets have a look at how to output what you’ve done in your macro!
Macro Output
As I just mentioned, the Macro Output tool is where the results of your macro’s workflow come out. You can actually have multiple Macro Output tools in a single Standard macro, this can be useful if you want to output data at multiple stages during your macro workflow. Much like the Macro Input tool there are multiple ways of adding a Macro Output tool, either:
Click on the “Interface” tab and drag in the Macro Output tool.
Search “macro output” in the top right search bar.
Or right click on a Browse tool and select “Convert to Macro Output”.
The final condition (which has likely already been automatically applied by this stage) for a Standard macro is to go to the “Workflow” tab in your Workflow Configuration on the left of the Alteryx Designer interface and check the “Macro” button, then select “Standard Macro” from the drop down menu.
But What About the Actual Standard Macro?
You may have noticed by now that I’ve only showed you how to start and end a Standard macro, but nothing in between! Well, the reason for this is – what goes in between can be anything you want it to be. Standard macros don’t add any functionality beyond convenience and therefore are no different from a normal workflow except for in the ways I have already mentioned. You may want to use them to access an API or save the workflow that solves a complex calculation; ultimately it is up to you. If you would like to try your hand at some Alteryx macro challenges, you can find them here. Otherwise stay tuned for my next blog, which will show you how you can create and use Batch and Iterative macros!