Macros
A macro is a workflow or group of tools combined into a single tool that you can insert into another workflow. Create a macro to save and automate an analytic process you perform repeatedly. Use the macro within a workflow without the need to recreate the analytic process each time.
Save a macro as a .yxmc file for use in Designer or share it with other users via the Alteryx Community Gallery or your company's Server.
Macro Types
Standard macro: This macro is designed to package a process in a workflow as a tool that can be inserted into a workflow.
Batch macro: This macro runs multiple times in a workflow and creates an output after each run. The macro runs once for each record or a selected group of records in data. The macro requires a Control Parameter tool as an input.
Iterative macro: This macro runs in the workflow the number of times set in configuration or continuously until a condition is met.
Location Optimizer macro: This macro is an iterative macro that can be used in network analysis to identify an optimal location or locations.
Build Macro
A macro consists of a workflow and a user interface created using Interface Tools. Go to Interface Tools and Interface Designer Window for more information. Alternatively, a custom user interface can be created using the HTML - GUI Library tool.
To build a macro...
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.
Create a new workflow or open an existing workflow.
Add a macro input:
If the workflow doesn't 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.
Add and configure a Macro Output tool.
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:
Select the canvas, and select the Workflow tab in the Workflow Configuration window.
In Type, next to Macro, select a macro type.
Convert to Macro
In addition to building a macro from scratch, you have the option to convert an existing workflow (or a portion of the workflow) to a macro. Before you convert to a macro, review these requirements and limitations:
You need to run the workflow first and browse everywhere data is available.
You need to save the workflow before converting to a macro.
The selected tools need to be in a continuous path and connected to each other (Comments, Explorer Boxes, and Tool Containers are exempt from this).
The selected tools must not contain errors.
The selected tools must not contain any In-DB tools.
The selected tools must not be connected to any action tools.
The selected tools must not contain a Python tool.
The selected tools must not include data that contains Spatial data types, BLOB data types, or Report data types.
To convert to a macro...
Select at least 1 tool in a workflow. Click and drag on the workflow canvas to select multiple tools.
Right-click one of the selected tools to open the tool menu.
Select Convert to Macro from the dropdown to open the Create Macro window.
In the Create Macro window...
Enter a File Name for the macro.
Choose a Location to save the macro.
Choose an Icon for the macro.
Select OK to convert your workflow or a portion of the workflow to a macro. Select Cancel to abandon this process.
The newly-created macro file opens in a new tab in Designer whereas the original workflow shows that selected tools were converted to a macro.
Save Macro
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...
Select File > Save As.
Locate a folder on your computer or network where you save macros.
Enter a unique name for the macro and select Save.
To share workflows that use 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. Go to Workflow Management and Workflow Dependencies for more information.
Create Macro Repository
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.
Select the "+" button.
In Category Name, enter a name. The default name is Macros.
Select the "..." button to browse to the location where you save macros on your computer or a network.
Subfolders in a search path cannot be added individually if their parent folder already exists in the Macros repository.
To set a default repository location...
Select the repository search path in the list.
Select Set as Default. An asterisk (*) displays next to the default repository.
Use Macro in Workflow
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 use a specific macro version in your workflow, right-click the macro and then select the version you want to run. Macro versions must all be stored in the same directory. You can configure this location in User Settings.
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. Go to User Settings for more information.
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 use 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. Go to Workflow Management and Workflow Dependencies for more information.
Sample Macros
Macros are included in Designer to help you learn to use and create macros. To access macros...
In Program Files on your computer, go to
\Program Files\Alteryx\bin\RuntimeData\Macros
.In Designer...
Go to Help > Sample Workflows > Use scripting and automation tools > 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.
Access apps published to the Alteryx Community Gallery.