Macros in Alteryx – Standard Macro

Macros are generally used to replace the repetitive process thereby saving time. They are also used when the result needs to calculated based on user input or parameters. Based on the requirements, one can create simple to complex macros. In Alteryx as well, we can create macro for the same purpose. Continue reading to know more about the macros and their creations in Alteryx.

Types of Macros

1.      Standard Macro

2.      Iterative Macro

3.      Batch Macro

In this blog, I will be explaining how to create a Standard Macro. Also check my blogs on Iterative and Batch macros where I have explained in detail how to create them.

What is a Standard Macro?

Those having a little bit of experience with software programming can consider this macro similar to a user-created function that takes some input and returns an output. In Alteryx one creates a workflow that takes some input and using some of the tools generates the expected output.

How to create a Standard Macro?

Let’s create a simple standard macro to understand it better. In the example, I will create a Multiplicator macro which

a.      enable the user to select the field(s),

b.      enable the user to provide a multiplication factor that must be multiplied with the user-selected field(s) and

c.      create a new field(s) with and update it/them with the results.

The important tools used to create macros are placed in the Interface tool panel, as shown below.

Step 1: Creating a running Work Flow

First, we need to create a workflow that works correctly, which is very important. We later convert this workflow into a macro. In order to create a workflow that works, we will insert a test input in the canvas using the Text Input tool that also helps us to test our macro. Then we insert a Select tool, which is used to include the field(s) based on the user input. Followed by we will insert a Multi-Field tool that will multiply the selected field(s) with the factor and create a new field(s). And finally, a Browse tool to display the output. So the initial workflow will look like below.

Using the Text Input tool, I created a dataset consisting of three fields A, B and C and three rows with values, as shown below.

In the Multi-Field tool, I created an expression [_currentfield_] * 5, as shown below. The variable [_currentfield_] in the expression holds the user-selected field(s) which will then be multiplied with the factor 5.

Step 2: Converting the workflow into a macro

Now that we have a workflow that works correctly, we can convert it into a macro. For that we will convert the input into a Macro input and the output into a Macro output. To achieve this, select the Text Input tool, right-mouse click and select Convert to Macro Input. In the same way, convert the Browse tool into Macro Output.

After converting the input and output to macro input and macro output respectively, we can provide the corresponding anchor abbreviation for each of the tools to make it clear for anyone who use the macro. Select the Macro Input tool and change the Anchor Abbreviation in the Configuration area to “i”. In the same way, select the Macro Output tool and change the Anchor Abbreviation to “o”.

As per our macro requirement, an option needs to be provided to the user, to select the field(s) to be multiplied with the factor. To achieve this we will insert a List Box tool from the Interface pane. The Macro Input tool is connected to the List Box tool and the List Box is then connected to the Select tool. When the List Box is connected to the Select tool, an Action tool is automatically inserted in the canvas. In the Action tool, we can define the action that needs to be applied on the Select tool.

In the Configuration area of the List Box, update the text field with the relevant text that needs to be displayed. In the Properties area, select the possible data types of the input value. In our example we are expecting only numeric values, so select the relevant fields as shown below.

In the Configuration area of the Action tool, select the option Update Select with multi-select ListBox as shown below.

Now let us add the second option for the user input where the user can enter the factor that needs to be multiplied with the selected field(s). For this, we use the Numeric Up Down tool. This is connected to the Multi-Field tool. Just like in the previous step, an Action tool is automatically inserted in the canvas when Numeric Up Down and Multi-Field tools are connected.

In the Configuration area of the Numeric Up Down tool, enter the text that needs to be displayed and update properties of the value as shown below.

In the Configuration area of the Action tool, we need to define the action that needs to be applied to the Multi-Field tool. In the expression ([_currentfield_] * 5)  defined earlier in the Multi-Field tool, the numeric value needs to be replaced with the user-provided value. For this, we need to make the changes as shown below. This ensures that the numeric value in the expression is always updated with the user-provided value.

Step 3: Saving the macro and inserting it into another workflow

Before saving we need to change the type of the workflow to macro. From the Workflow tab of the Workflow - Configuration area, we need to select Type as Macro and from the drop-down select Standard Macro as shown below. Now let us save our macro. The macro workflow will be saved with the .yxmc extension.

The saved macro can now be used in another workflow. Open the workflow where you want to insert the macro. On the canvas area, right-mouse click and select Insert and then Macro. From the Open File window, browse the location where you saved your macro and select it to insert it in the canvas. Connect the macro input and output of the macro with the respective tool.

Now you have learned how to create a Standard macro. I hope you enjoyed reading this blog.

Author:
Sreekanth Arathil Condoth
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab