community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.
#SANTALYTICS

The highly anticipated Alteryx Community tradition is back! We hope you'll join us!

Learn More
We will be upgrading the Gallery to our 2019.4 release this Saturday, December 7th beginning at 9:00am MT. We expect the outage to take last approx. 2.5 hours.

Getting Started with Standard Macros

Alteryx
Alteryx
Created on

How to get started with using Standard Macros

 

When you have a repetitive task to complete processing data across different columns, data sources, and/or workflows, a Standard Macro may help automate that task.

 

If you notice a part of your workflow has become a series of the same tools being reused multiple times like the example below, it may be time to consider using a macro. 

 

EricWe_0-1574773249960.png

 

This article will help you get started with using Standard Macros. There are examples, recorded training sessions, and other articles to further your knowledge listed in the Common Issues and Additional Resources sections.

 

You can think of a Standard Macro as a shared process that can be reused for different fields, data sources, or workflows. It packages a process completed with a set of tools as a single tool and creates one output.

 

A Standard Macro can be configured with questions that the user answers to dynamically configure the macro before running the workflow. By answering these questions, the user can update the values used.

 

The macro is saved as a separate file with a .yxmc extension, and it can be shared for use in other workflows. The set of tools in a Standard Macro is run once and then it is done.  

 

The macro type is selected on the Workflow tab in the Workflow - Configuration window.

 

EricWe_1-1574773249970.png

 

There are a few basic steps to configuring a Standard Macro. Select a Macro Input Tool from the Interface Toolbar to start. When adding a Macro Input Tool to the canvas, the workflow type will automatically change from Standard Workflow to Standard Macro.

 

Placeholder input should be added to the Macro Input Tool for developing and testing the macro. The placeholder data in the Macro Input Tool will be replaced by the workflow data once the macro is complete.

 

You can either create test data in with the Text Input option or select a File with the data you want to use. This test data should have the same number of columns as the workflow input that will run through the macro and the same data types.

 

Notice in the Macro Input Configuration screen that the Show Field Map checkbox is selected. This option will allow the user to click on the macro icon once it is added to a workflow and select the columns that will map to the fields used in the Macro Input Tool as placeholder data.

 

EricWe_2-1574773249978.png

 

The Anchor Abbreviation in the screen capture above is set to 1. It will appear on the matching anchor for the macro when it is added to the workflow. For example, here is a Standard Macro with inputs 1 and 2 as well as outputs 3 and 4. 

 

EricWe_3-1574773249980.png

Once you have your macro input configured, you can create the process that you want to automate. Here a new column is created that adds 5 to the values coming from the Macro Input tool.

 

EricWe_4-1574773249984.png

Keep in mind that you can configure the macro with questions, and have the user set the values used in the macro.  In this example, a Text Box Tool was added. When the Q output anchor of the tool is connected to the lightning bolt anchor of another tool, an Action Tool automatically appears. This tool gives the user the ability to define the Action that will occur with the user’s answer to the question.

 

EricWe_5-1574773249988.png

 

In this example, the Action Tool is going to update the Formula, and replace the number 5 with the number typed in by the user.

 

EricWe_6-1574773249995.png

 

Once the macro is completed and saved as a .yxmc file, it can be added to a workflow as a tool selected from the Insert Tool Menu. The record values from the workflow will replace the values in the Macro Input Tool.

 

To add a macro to a workflow right click on the canvas and select Insert Tool, then look for the Macro option at the bottom.

 

EricWe_7-1574773250009.png

 

If the Show Field Map option was selected in the Macro Input tool, the user is prompted to map the field(s) from the workflow to match the placeholder data in that tool. Since a Text Box Tool was added in the macro and set to replace a number in the Formula Tool, the user is also prompted for the number that will be used in the addition function to produce the result. The prompt is like a question from the Text Box Tool asking what number to use for replacing the placeholder value in the Formula Tool.

 

EricWe_8-1574773250014.png

 

The Standard Macro can be a superhero in your workflow and make it easier to complete. You can customize your macro with a picture by going to the View menu and selecting Interface Designer. Next, click on the Properties icon and select the Custom Icon option. 

 

EricWe_9-1574773250015.png

 

The Interface Designer is also helpful for arranging the questions shown to the user and debugging the macro. For details see: Interface Designer Part 1.

 

Common Issues

 

You may need some sample workflows with macros to help you get started. In Designer, try going to the Help menu, then Tutorials, and select the Intro to Macros option. There is a two-part workflow lesson for beginners. Also, sample macros for different use cases are available in Designer by going to Help, Sample Workflows, Use scripting and automation tools, and Build a Macro. When viewing the workflow, right-click on the macro tool, and then select the option to Open Macro. This will open the macro workflow packaged for that tool on a separate tab.

 

There are recorded training sessions for macros available on the Community website here: Recorded live training label: Macros.

 

Once you have started creating macros, you may want to organize and access them in a Designer Toolbar for easy reuse.

 

You can have Designer automatically add macros to a Macro toolbar through User Settings. Go to Options, User Settings, Edit User Settings, and select the Macros tab, then click on the plus sign button. You can add a folder location in the Search Path. Any macros stored in this location will appear in a toolbar category titled Macros that is added by Designer.

 

EricWe_10-1574773250019.png

 

If you want your macro to appear in other existing Toolbars, use these instructions: Macro Installation.

 

Additional Resources

 

Macro Help Page

Macro Input 

Macro Output 

Tool Mastery Apps and Macros 

Best Practices for Sharing Macros 

Batch Macros 

Iterative Macros