What is a Macro and why should we use one?
A macro is basically an Alteryx Workflow that is compressed down to be a single tool. They allow you to take a section of a workflow that you need to repeat. You can then use this macro in other workflows.
There are 3 types of Macros –
I am going to run through a very basic example of a Standard Macro. You can download the data here to follow along –
Standard Macro example:
Our task – We want to be able to select a company name in our data and allow people to see everyone in that company.
1. First input the data using the Import Data tool.
2. We want to be able to filter the data by the Company Name. To do this, add a filter tool. Basic filter – Company Name equals ‘Fetch Global’.
3. This is the simple workflow we are going to use. We need to output this data and turn the workflow into a macro. To do this, go up to the interface tools and select ‘Macro Output’. Drop this anywhere in the workflow. Lightening bolts will appear on the tools, this indicates we are building a macro.
You can check this is a Macro by going to the Configuration window and selecting ‘Workflow’. It should look like the image below.
4. Now our workflow is set up as a Macro we need to add some more ‘Interface’ tools. We want to give the user the option to select a company using drop down. To do this, go to the ‘interface tools’. Add a ‘drop down’ interface tool to your workflow. Drag the ‘Q’ from the drop down tool to the lightening bolt on the top of the filter tool. The moment you do this, an action tool appears.
We need to give our Macro some instructions of what to actually do with the drop down tool. Enter the text that you want to be displayed to the user. In this case I have labelled this ‘Select a Company.
Select the ‘List Values’ and manually set values. This step only creates the user interface so we still need to create an action.
5. Set up the Action tool. Click on the action tool. Select ‘Filter’ > Expression – value = ‘[Company Name] = ‘Fetch Global**
6. Save your Macro as a .yxmc file and run the workflow.
7. Open up a new workflow to use your macro. Right click on the white space and navigate down to macro. The Company Macro should be located here if you still have your original macro workflow open.
As you can see, the Macro icon is currently just a blue circle.
8. We can personalise the macro icon. Go back to your Macro workflow and go to ‘View’ on the top tool bar. Select Interface designer > edit > interface designer.
Select the bottom icon on the left and then choose a custom icon.
Your macro is now ready to use as a tool in a future workflow! You can add as many tools and interface options to make this more useful.