Macros
A macro is a workflow or group of tools built into a single tool that can be inserted into another workflow. Create a macro to save an analytic process you perform repeatedly. Use the macro within a workflow without having to recreate the analytic process each time.
Save a macro as a .yxmc file to be used in Designer or uploaded for sharing in the Alteryx Analytics Gallery or a private Gallery.
- Standard macro: This macro is designed to package a process in a workflow as a tool that can be inserted in a workflow.
- Batch macro: This macro runs multiple times in a workflow, creating an output after each run. The macro runs once for each record or selected group of records in data. The macro requires a Control Parameter tool as an input. See Batch Macro.
- Iterative macro: This macro runs in the workflow the number of times set in configuration or continuously until a condition is met. See Iterative Macro.
- Location Optimizer macro: This macro is an iterative macro that can be used in network analysis to identify an optimal location or locations. See Location Optimizer Macro.
A macro consists of a workflow and a user interface created using Interface Tools. See Interface Tools and Interface Designer Window.
Alternatively, a custom user interface can be created using the HTML GUI SDK.
To build a macro:
- Create a new workflow or open an existing workflow.
- Add a macro input:
- If the workflow does not contain an input, add a Macro Input tool.
- If the workflow contains an input tool (like an Input Data or Text Input tool), right-click the tool and select Convert to Macro Input.
- Configure the Macro Input tool. See Macro Input Tool.
- Add and configure a Macro Output tool. See Macro Output Tool.
If you are using an existing workflow, select the portion of the workflow that you want to save as a macro, then copy and paste it on a new workflow tab.
By default, the workflow type changes to Standard Macro when a Macro Input tool is added to a workflow. The macro type defaults to Batch Macro when you add a Control Parameter tool to the workflow. To create an iterative macro, set the macro type to Iterative.
To set the macro type:
- Click the canvas, and click the Workflow tab in the Workflow Configuration window.
- In Type, next to Macro, select a macro type.
Save a macro for future use and sharing. Save macros with a unique name to a specific location. In Designer, you can create a macro repository mapped to a location on your computer or network to easily save macros and use them in a workflow.
To save a macro:
- Click File > Save As.
- Locate a folder on your computer or network where you save macros.
- Type a unique name for the macro and click Save.
To share workflows that uses custom macros, export the workflow to ensure that all workflow dependencies, including the macro, are saved with the workflow. The workflow must include a relative path to the macro. See Workflow Management and Workflow Dependencies.
In Designer, you can map to the location where you save macros and create a macro repository to easily save macros and use them in a workflow. Any macro .yxmc file in the selected location displays in the tool category on the Tool Palette.
To create a macro repository:
- Go to Options > User Settings > Edit User Settings > Macros.
- Click .
- In Category Name, type a name. The default name is Macros.
- Click to browse to the location where you save macros on your computer or a network.
Sub-folders in a search path cannot be added individually if their parent folder already exists in the Macros repository.
To set a default repository location:
- Click the repository search path in the list.
- Click Set as Default. An asterisk (*) displays next to the default repository.
To use a macro that is saved to your macro repository, find the macro in the Tool Palette or use Search.
To use a macro that is not on the Tool Palette, right-click the workflow canvas and select Insert > Macro. Any macro that is currently open on the canvas can be selected from this list or you can browse to the location of a different macro *.yxmc file.
To differentiate a macro from a tool within a workflow, select the Display macro indicators on tools option to display the icon in User Settings > Canvas. See User Settings.
To view a macro's workflow, right-click the macro in a workflow and select Open Macro. A macro in a workflow is automatically updated when changes made to that macro are saved.
To share workflows that uses custom macros, export the workflow to ensure that all workflow dependencies, including the macro, are saved with the workflow. The workflow must include a relative path to the macro. See Workflow Management and Workflow Dependencies.
Macros are included in Alteryx Designer to help you learn to use and create macros:
- Program Files on your computer: Go to \Program Files\Alteryx\bin\RuntimeData\Macros.
- Designer:
- Go to Help > Sample Workflows > Tutorials > Build a Macro.
- Some tools in the Tool Palette are macros. For example, the Create Samples tool and Data Cleansing tool. Right-click a tool and select, Open Macro if available, to view the macro workflow.
- Alteryx Analytics Gallery: Access apps published to the public Gallery.