Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

Guide to Creating Your Own R-Based Macro Series


Most of the Alteryx advanced analytics capabilities - including most of the tools in the Predictive, AB Testing, Time Series, Predictive Grouping, and Prescriptive categories - are built as R-based macros under the hood. If there's a piece of functionality that you're looking for that's lacking in Alteryx but is available in R and you have modest R coding abilities, you can extend Alteryx by creating your own R-based Alteryx tool.


The macro creation process involves four steps (quick links to the guides in the series😞

  1. Find and install an appropriate R package to provide the needed functionality.
  2. Develop an Alteryx workflow that makes use of the relevant R functions via the use of an R tool. This workflow becomes the basis of the macro.
  3. Create a macro that provides the basic functionality you want, and test it in a new workflow.
  4. Polish the macro by documenting it, giving it the ability to generate a report, and doing other things to make it more polished.

 The various Alteryx files created in this tutorial are attached to this post. 


Once you've created the new tool, don't forget to share it with the wider community by publishing it to the Alteryx Analytics Gallery.




Recently I have been working with an existing customer that is considering expanding the use of Alteryx within their organization to include other groups. Some of those groups are focused on developing predictive analytics models, and currently its members are using a number of different software products. Based on this, there are certain features that they often use in some of those products that are not available "out of the box" in Alteryx. While these features are heavily used by some members of this group, they aren't as widely used in general. A trade-off we face in developing Alteryx is to provide generally needed functionality without blowing up the number of available tools to where their sheer number becomes overwhelming to new Alteryx users.


In a number of instances we have developed new tools at the request of customers to address their needs, providing them with the tools immediately, and then folding them into a subsequent release of the product or publishing them to the Predictive District on the Alteryx Analytics Gallery. A particular case in point is the MB Affinity tool, which was part of the 10.0 release of Alteryx. The MB Affinity tool provides cosine similarity/distance measures for items. This is a common method used in creating recommendation systems of the "people who bought this item also bought" variety.


Getting back to the issue faced by the predictive analytics team of our current customer, one feature of another product that they currently use, which isn't currently pre-packaged in Alteryx, is a tool that examines the importance of potential numeric predictors for a categorical target field using an entropy based measure known as information gain or Kullback–Leibler divergence. In this series, I illustrate how to create an Alteryx macro that provides this measure.