This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
This article will walk you through how to install a macro, so that it can be accessed from the tool palette in the Designer.
Download or save a macro to a directory
Open Alteryx Designer
Click Options > User Settings > Edit User Settings
Click the Macros tab within the User Settings window
Click the + icon and select the directory used to save your macro(s)
Enter a Category Name for the directory to appear as in the Designer
Macro(s) will now show up in the category specified
Things to consider:
- all macros within the folder specified will be installed
- the category specified within the macro Meta Info will take priority over the Category Name specified in step 6:
A macro can be added to a workflow without installing it. Do this by right-clicking on a blank-portion of your wokrflow and selecting Insert > Macro.., then navigate to the location of the macro you'd like to insert.
Fact: workflows are the best. Look it up. They’re all about getting things done and, with hundreds of tools and the ability to integrate external processes , there’s no shortage of things you can get done. We know that there are some areas of analytics that require a little extra firepower, however, and that’s why you can leverage your workflows in apps and macros for added functionality.
The Dynamic Replace Tool is an under-utilized tool in the Developer Toolset that is very powerful. It allows for dynamic formulas or conditions to be used in your workflow. It was first introduced in Alteryx 6.1 . It’s one of the few tools that is currently multi-threaded which makes is fast.
There’s a lot going on in the world of analytics. Endless data stores and insight are at the other end of an internet connection and, as analysts, we’re always in on the action. Being in the thick of the fray with data whizzing by at lightning speeds, being equipped with the right tools is a must. Like you, Alteryx also likes to live dangerously, and we’re always ready for action.
Ever needed to learn how to use an Iterative macro? This article walks you through the process with a basic mathematical problem highlighting how the data moves through the macro and loops back to continue processing.
Iterative macros can be used to repeat a process a desired number of times. Say, for instance, you want to generate a list of 10 random numbers. Rather than create ten different formulas for the values, wouldn’t it be great to simply tell Alteryx how many values to create, hit “Run”, and voila? Well, with a few clicks to create a simple iterative macro and some knowledge of engine constants, you can! With the particular examples provided in the sample workflow, I’ve imagined two tasks. One is to generate 10 random numbers between 0 and 100. This input data only requires the number of values to output (Figure 1, A). The second task is to create a number of values associated with a group. In this case, the input data has two fields: the Group Name and the number of values to create for that group (Figure 1, B). The input data feeds directly into the iterative macro which begins the process of repeatedly generating random values the specified number of times.
Figure 1: Input data for the two sample scenarios
The number of times the macro repeats the process of generating a random value is controlled by two things: the user-defined value of repetitions in the input data and the engine iteration number within the macro. Once a workflow is defined as an iterative macro, certain constants are then made available for use within the workflow (Figure 2). For example the engine iteration number, a constant which records the number of times a macro has run, is a usable field in the Formula tool (Figures 3). As a usable numeric field, I can insert the e ngine i teration n umber in a formula to record the number of repetitions needed to generate the values I need. Because the number of Engine iterations starts at “0”, adding “1” to this value scales it appropriately to the value(s) entered in the input data.
Figure 2: Iterative macros activate engine constants, and specifically the iteration number, for use within workflows. Note that iteration numbers begin at 0
Figure 3: Engine constants can be used to build expressions in the formula tool
This engine iteration number helps control the number of times a repetitive process runs by serving as a logical comparison in a filter tool: does the number of values I set out to create equal the number of times the macro has run? In other words, does my input data value equal my engine iteration number +1? If the answer to that question is “no”, then the workflow will run again after storing the data it just created using a union tool. If that logic’s answer is “yes”, then the process has generated the desired number of outcomes and leaves the iterative macro, along with any previously generated data that has been unioned from previous iterations (Figure 4).
Figure 4: If the number of desired values has not yet been created (per the logic of the filter), then the process of generating values will repeat. Regardless, the random values that are created are stored with a union tool and output once the Filter's logic is "True"
After leaving the macro, the data can be summarized to visualize grouped data, selected for certain fields, or even fed through Data Investigation tools for further analyses (see attached v10.6 workflow).
Alteryx 5.0 gave us the ability to create Batch Macros. This type of Macro is designed to run repeatedly, changing the configuration of the module based upon the Control Parameter input. The Batch Macro will repeat the module as needed for every record received by the Control Parameter that exists. The Control Parameter is changed by an Action in the macro properties In Alteryx 6.0, the ability to use Iterative Macros was added. An Iterative Macro will run through every record and then loop the records back through the module again. It will repeat this process until a condition is met, or a specified number of loops is reached. The user can set both the number of iterations and a condition within the macro. Also, the user can set which records will loop back through again. Using the constants in the module the user can manipulate the variable used for the iteration. So, if the process runs the module with the same configuration, but with multiple parameters, a batch macro would be used. An example would be using the Directory tool to run the same module on multiple files. The changing of the file path would be the parameter change. If the process requires changing a variable within the module a set number of times or until the desired outcome is achieved, then an iterative macro would be used. An example of this would be expanding the size of a polygon incrementally until it encompasses a desired amount of points.
If you have ever created an Alteryx macro, you know that debugging can be somewhat difficult. Thanks to our very own Dan Jones on the Content Engineering team, this no longer has to be such a difficult experience! Recently, he published an Engine Works blog post outlining the X-Ray Browse Macro. The X-Ray Browse Macro will ultimately look into the workflow of a current, in-use custom macro and "bubble up" the messages to your parent module or app. Why is this important? Debugging macros has always been a bit more difficult as it requires you to create a separate module with real-life data, not just the data you used in developing your macro. This can create multiple iterations of the same macro using different datasets, which can be very inefficient. Thanks to the X-Ray Browse, you can now create your testing parameters within one parent module, and see each and every message the underlying macro generates. For more detail (and to download the macro), please head on over to Dan's blog post. Thanks, and until next time! Chad Follow me on Twitter! @AlteryxChad
Let's say you've got your eye a new car or home. Before visiting with a banker you'd like to run some numbers and see if payments fit within your budget. Excel has a couple of functions that can help you. To calculate your payment, you use the =PMT function. You can even take it a step further and calculate how much you'll pay in interest (=IPMT) and principle (=PPMT) for your first payment and each payment thereafter.
Payment applied towards principal (payment number 1 of 60):
Payment applied towards interest (payment number 1 of 60):
Just do that 59 more times, incrementing 'Loan Payment Number' by 1 until you reach 60 and you will create your very own amortization schedule. If this had been a home loan with a 30-year term (360 months), you would only need to update this spreadsheet 359 more times!
That's where an iterative macro can help and save you a lot of time. Attached is an app with an embedded iterative macro. It does the same thing the Excel spreadsheet above does but it loops through each payment period and calculates how much of your payment goes towards principal and interest and recalculates your new loan balance. When you run the app, you'll enter your loan amount, APR and the number of months in the term (length) of the loan.
Macros can be designed to treat nearly every and any repeatable operation in Alteryx. If you’re working with formalized, established, processes and prefer not to duplicate work, or you’ve just found a handful of useful macros on our Public Gallery, being able to maintain macros is a must.
Whether you’ve installed the macro or built it yourself, the Workflow Configuration Meta Info tab will be crucial:
1: A custom workflow name will appear as the macro tool name in both the Designer or Gallery; it will override the macro file name.
2: The description specified in this tab will help users grasp the how to use the macro; it is also listed on the Gallery if shared there.
3: Tool Version helps to differentiate between iterations of the same macro, it will also push version updates to the Gallery if re-posted, updating the version numbed listed there.
4: Category Name will override the macro’s default to appear in your macro directory for another – in this example the macro will be found next to the other Designer Address Tools.
5: Any search tags listed here will be matched keywords when searching in the Designer or Gallery for the macro.
6: Any author information provided is also listed in the Gallery if the macro is posted; it also may help when sharing.
If you’re sharing your macro, be sure to also include any tool assets that are used (including nested macro files) by attaching them to their associated tool!