An Introduction to Alteryx Macros

Before today, my knowledge of macros as a concept roughly covered the fact that they existed, and maybe what they are on the broadest level. I think that in Alteryx, the definition that helped me the most as a beginner is that macros are used to make a sequence of tools available to us as a 'single instruction' (or in our case entering one 'macro tool' into a workflow instead of all of said tools). By doing this, it saves us from having to manually configure things repeatedly when they could be done automatically. After one day of being taught macros, I don't think I'm qualified to teach anybody how to make them, but maybe I can try to successfully document the different types.

We covered three types of macro: Standard, Batch, and Iterative.

Standard Macros:

A standard macro runs from an input to an output once, allowing us to apply some logic to a certain part of our workflow.

Our example macro took an input of pay rates for different jobs, but we wanted to format them as currencies when outputting them to a 'business document'. The main distinctions from a regular workflow are the interface tools at the top. They are what allow the user to interact with the macro from the workflow. In this case, they allow us to choose which fields to format, and the currency we wish to format those fields in.

Batch Macros:

A batch macro allows us to split our incoming data into separate 'batches', allowing us to automatically use slightly different logic on different parts of the input. To me, this seemed immediately familiar to how a 'for loop' in python or javascript would allow us to execute a set of statements over a sequence, depending on our desired outcome.

One of our example batch macros looked to apply a certain tax rate to a field, depending on how the tax rate differed between states. A batch macro must have a control parameter tool somewhere within it (the cog icon at the top of the macro).

Iterative Macros:

If batch macros are akin to 'for loops', then iterative macros can be compared to 'while loops'. The macro will continue to run until a predetermined criteria is met, or the loop has hit the maximum number of iterations we decided to let it run for.

In our example iterative macro, the macro input is simply a converted text input stating 1000. After we choose a growth rate and investment target, the macro will continue to loop and reinvest the money until the filter is satisfied, which in this instance is us doubling our money. The reporting output will then tell us how many iterations (or years in our case) it took for us to double our money.

In conclusion, even after a single day of learning macros I can see how powerful these macros can become in a workflow, but it'll take me a bit more than a day to actually be able to confidently use them myself!

Author:
James Charnley
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
© 2024 The Information Lab