community
cancel
Showing results for 
Search instead for 
Did you mean: 

Engine Works Blog

Under the hood of Alteryx: tips, tricks and how-tos.
Sr. Data Science Content Engineer
Sr. Data Science Content Engineer

knitting.png

 

Editor's note: you may need some background on what Macro Maynia is. Find it here.

My submission for Macro Maynia might be a little more foreign to everyone than the examples in the coming weeks, but I am hoping to compensate for that with a clear writing and so many pictures.

 

Ready?

 

Macros are like knitting.

 

Yes, knitting.

 

Yes, I am pretty much a grandma.

 

ninetynineproblems.pnghttps://www.buzzfeed.com/alannaokun/important-life-lessons-to-learn-from-knitting

Bear with me.

 

2019-05-01_8-25-34.png

 

Standard Macro

 

standard macro 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.

 

2019-05-01_8-38-48.png

With the power of a knitting pattern, anyone and everyone can (and should) make a Yoda hat for a baby!

            

yodahats.png© MaiyaMayhem, © rhianelaine, © ADAllen, by ladybugles, by stefanijaye, by laurenswool

Using a pattern can also help prevent outcomes like this:

 

a5965a9ea291e1aa9b83276d962993da.jpgnow 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, many Alteryx tools are macros!).

 

Batch Macro

 

Imagine you wanted to knit matching sweaters for your family. Maybe for Christmas, or a super awesome family photo (or both!).

 

family2.jpg

 

To make the sweaters, you would repeat knitting a pattern for each member of your family, all the way through.

 

family1.jpg

 

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!

 

Dude-16.jpgThe Little Dude by Andrea Rangel - https://www.ravelry.com/patterns/library/the-little-dude

Knitting patterns often come with instructions for different sizes. 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).

 

Iterative Macro

 

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.

 

putyourflareon.png© putyourflareon

 

2019-05-01_9-03-35.png© Kemper Wray

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.

 

2019-05-02_14-44-31.pngPattern 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.

 

KnittingDarthVader.jpg

 

Comments
Asteroid

@SydneyF 

Your article made me laugh.  I needed that on a Monday morning.

Sr. Data Science Content Engineer
Sr. Data Science Content Engineer

@papalow 

 

Seeing your comment made me so happy - I needed that on a Monday morning 🙂

Alteryx Certified Partner
Alteryx Certified Partner

omg @shoesnsocks4 ...I can’t believe you didn’t write this blog post 😂

 

Another awesome post @SydneyF! Will have to point people to this next time I get the question 🙂

ACE Program Specialist
ACE Program Specialist

Love love love this blog post. You made it so easy to understand @SydneyF! And as always...meme game on fiyah!

Labels