Macros

Version:
2019.3
Last modified: September 26, 2019

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 (gallery.alteryx.com) or a private Gallery.

Types of macros

  • 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.

Build a 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 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.

  1. Create a new workflow or open an existing workflow.
  2. 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.
  3. Configure the Macro Input tool. See Macro Input tool.
  4. Add and configure a Macro Output tool. See 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:

  1. Click the canvas, and click the Workflow tab in the Workflow Configuration window.
  2. In Type, next to Macro, select a macro type.

Save a 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:

  1. Click File > Save As.
  2. Locate a folder on your computer or network where you save macros.
  3. 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.

Create a 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:

  1. Go to Options > User Settings > Edit User Settings > Macros.
  2. Click .
  3. In Category Name, type a name. The default name is Macros.
  4. 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:

  1. Click the repository search path in the list.
  2. Click Set as Default. An asterisk (*) displays next to the default repository.

Use a macro in a 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. 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.

Sample macros

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 Alteryx Public Gallery.
Was This Helpful?

Need something else? Visit the Alteryx Community or contact support.