Skip to main content

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.

  1. Create a new workflow or open an existing workflow.

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

  3. Configure the Macro Input tool.

  4. 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:

  1. Select the canvas, and select the Workflow tab in the Workflow Configuration window.

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

  1. Select at least 1 tool in a workflow. Click and drag on the workflow canvas to select multiple tools.

  2. Right-click one of the selected tools to open the tool menu.

  3. Select Convert to Macro from the dropdown to open the Create Macro window.

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

  5. Select OK to convert your workflow or a portion of the workflow to a macro. Select Cancel to abandon this process.

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

  1. Select File > Save As.

  2. Locate a folder on your computer or network where you save macros.

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

Update Missing Macro

Historically, when you imported or opened a workflow with an existing macro, if that macro was missing from the workflow (due to a name change, moved location, incorrect packaging, etc.), the macro presented a black question mark icon (UnknownTool_71x71.png) on the workflow canvas.

You then had to go through a painful process of manually re-adding the macro and reconfiguring the workflow to get things working correctly.

Now, you have the option to identify the correct macro locations before the workflow opens and avoid the missing macro error altogether!

Tip

Go to Update Missing Macros for additional details and use cases.

Update Missing Macros in Workflow

When you attempt to open a workflow (YXMD, YXMC, or YXWZ file) with a missing macro, a pop-up Update Missing Macros window appears in Designer to alert you of the issue.

update-missing-macros-1.png

The Update Missing Macros window communicates that the workflow references at least 1 macro that is missing or inaccessible. The message provides details for these macros. Note that the window lists a maximum of 3 missing macros (though more might be missing).

You have 2 options:

  • Update: Select Update to update the file paths for the missing macros. This opens the original workflow where you can make changes. However, Designer doesn't automatically save the workflow. After you make updates, you can use File > Save As or the Ctrl+S (Save) keyboard shortcut to save a new version of the workflow or overwrite the original workflow if needed. Note that you need access to the missing macro files and be able to browse to their locations. If you received the workflow from someone who failed to include the macros, you will likely need to reach out to them and ask them to provide you with the files. If you elect not to update the file paths here, the workflow will open with the missing tool icons.

  • Close (don't update): Select Close. This opens the original workflow without the updated macros. The macros will have the missing tool icon (UnknownTool_71x71.png), and if you want to fix these missing macros later, you will need to add the macros and reconfigure them manually.

Update Macro

To update the macros, follow these steps:

  1. On the Update Missing Macros window, select Update.

  2. This opens an Update Missing Macros window, similar to the Workflow Dependencies experience. Here, you can edit each missing macro's file path and update its location. Note that you can't edit non-macro dependencies via this window.

    update-missing-macros-2.png
  3. Select the edit pencil icon associated with a missing macro. This opens File Explorer where you can browse to the correct macro location. Select the macro and then Designer updates the macro path and changes the path's color to green.

  4. Do this for any additional macros and select OK when you finish. You can also select Cancel at this point, which opens the original workflow with broken file paths (missing tool question mark icons).

  5. If you updated macro paths and selected OK in the previous step, your workflow opens with the updated macros and no missing tool icons.

If the macro is the same and the number of input and output connections from the new macro paths matches the number in the workflow, Designer attempts to make the connections automatically. However, in some cases (for example, if you connect a different macro with the same number of inputs and outputs), Designer isn't able to make the connections. If this is the case, you need to manually review and configure them. 

Important

When you use the Update Missing Macros feature, Designer updates the original workflow, however the workflow isn't automatically saved. You can use File > Save As or the Ctrl+S (Save) keyboard shortcut to save a new version of the workflow or overwrite the original workflow if needed. If you close the workflow without saving, your updates will be lost.

Close (Don't Update)

If you want to open the workflow and not update the macros, follow these steps:

  1. When you attempt to open a workflow with missing macros, the Update Missing Macros window displays.

  2. To open the workflow without updating the macro locations, select Close.

  3. Your workflow opens, and the missing macros display the missing tool icon (UnknownTool_71x71.png). If you want to update the missing macros, you need to add the macros and reconfigure them manually.

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

  1. Go to Options > User Settings > Edit User Settings > Macros.

  2. Select the "+" button.

  3. In Category Name, enter a name. The default name is Macros.

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

  1. Select the repository search path in the list.

  2. 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. You can select any macro that is currently open on the canvas 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.

Macro Templates

If you find that you reuse many components and configurations in your macros, you might want to create templates to save time. Go to Templates to learn how to save your macro as a template.

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.