Inspiring Ingenuity

Alteryx, Bicycles and Teaching Kids Programming.

Alteryx: Simple Batch Macros

4 Comments

This comment asks how to create a simple batch macro in Alteryx.  Batch macros can seem very intimidating, but they are really quite easy to build once you understand how they work.

The 1st thing to understand is that you will be building 2 modules, not 1.  The batch macro itself is designed to process a single item, however you define item, and the module outside sends in a list of items.  In the case of this specific question, he would like to read a list of files, do some simple processing on them and then write them back out.

Since I don’t have the commenter’s data, I made a set of CSV files for each US State with the 2000 & 2010 Census population for each county.  For each file I want to read it in and then calculate the % growth in a new field and write it back out.

imageSo to start, we make a module that does the processing we need for a single file.  This is a very simple module, it just reads a file and writes a file.  The next steps are just to make it a batch macro, add 2 control parameters, 1 each  for input & output file as well as making their corresponding actions.

image At this point, we make a new module that will enclose the batch macro.  This module isn’t doing the processing, it is just producing the list of items to process.  A Directory tool, followed by a formula to create input & output file names followed by the macro we made above.  You can see from the below screenshot that it quickly loops through all the input files and processes them.

All the modules and input files can be found here.  As you can see, batch macros are not that scary after all…

Thanks for reading,

ned.

image

Advertisements

4 thoughts on “Alteryx: Simple Batch Macros

  1. As always a very simple, clear explanation Ned. Is it worth pointing out to your readers that while this a good illustration of a batch macro there are always multiple ways of achieving things in Alteryx, and this is no exception e.g. using *.csv in the input tool or using the dynamic input tool.

  2. Hi, your macro files are no longer accessible. Can you please re-post them?
    Thank you

  3. Just a blank page, can`t establish a secure connection. can you please check file is shared?