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.
A standardmacro can be thought of like knitting with a pattern. It’s a set of instructions that are repeatable. If I want to knit a hat, a scarf, a sweater, or a blanket, I can find a pattern that will tell me exactly how to do it.
Just like a knitting pattern, a standard macro allows you to package a process in an easily sharable format, so anyone can repeat the same process to get an expected outcome.
With the power of a knitting pattern, anyone and everyone can (and should) make a Yoda hat for a baby!
Using a pattern can also help prevent outcomes like this:
now imagine this with your dataA standard macro is a pattern (workflow) bundled up into a neat package. You can use standard macros the same way you would use any other tool in an Alteryx workflow (in fact, manyAlteryxtoolsaremacros!).
Imagine you wanted to knit matching sweaters for your family. Maybe for Christmas, or a super awesome family photo (or both!).
To make the sweaters, you would repeat knitting a pattern for each member of your family, all the way through.
Generally speaking, this is what a batch macro does. It repeats a process for a provided number of inputs. If you have twenty family members, you would knit twenty sweaters (and not see the light of day again for six months). If you have twenty “batches” (groups) of data you needed to process, the batch macro would repeat the process twenty times, once for each item or group of data.
But wait a minute, little Timmy and Aunt Andrea don’t wear the same size!
The Little Dude by Andrea Rangel - https://www.ravelry.com/patterns/library/the-little-dude
Knitting patterns often come with instructions for differentsizes. The instructions change a little bit depending on what size sweater you need to make, but the process and the outcome are effectively the same. You’ll knit a little more to make a larger sweater or less to make a smaller sweater, but the process and outcome are very similar.
A batch macro can work the same way. A batch macro will repeat a process for a given set of data, tweaking the process slightly for each group within the data. If you need to calculate a 5% tax for purchases in Colorado and a 10% tax for purchases in Washington, you can do so in batches, using the same process but a different tax rate (I have no idea what the tax rates actually are).
After spending half a year knitting sweaters, let’s imagine we are not totally sick of knitting and now we want to make a blanket for our bed.
We all know blankets come in many different sizes. Often, instead of giving you exact instructions for each possible size of a blanket, many blanket knitting patterns will give you a set of instructions to repeat until you get to the size you want.
If we want to knit a blanket that is at least six feet long, we will repeat the pattern until the length measures to six feet (or more) in length, checking the dimensions at the end of each repeated set of instructions.
Pattern Iterations in a Blanket
This is how an iterative macro works. It repeats a process until a given condition is met. This condition, whatever it might be, (e.g., a certain number of iterations, a value threshold for the outcome of a repeated calculation, a true or false test if all pages have been downloaded from an API) is the stopping point. The macro isn’t sure how many times it will need to iterate to get to the end, but it will know when it is done. Iterative macros can be handy for any process that you're not sure how many times it will need to be repeated for a data set, or something that needs to be repeated a certain number of times that doesn't necessarily match an input list.
All the Macros
To summarize, standard macros are like knitting something with a single pattern, batch macros are like using a pattern to make multiple sweaters for a given list of people (one sweater per person, adjusting the size of the pattern for the person), and iterative macros are like knitting a blanket of a pre-defined size, where you repeat a given pattern until you meet the pre-determined threshold (the size of the blanket).
If this didn’t help you with understanding Alteryx macros, maybe you should pick up knitting. It’s a great hobby.