Another week is over and another section of Alteryx weekly challenges is (almost) finished for me. Almost, because I’ve left out a few difficult ones for a time when I’m more competent. The section I’m talking about is Macros.
As I mentioned in my post on Monday, we had some training on macros in Alteryx with Phil this week. It was super beneficial to me as beside learning about another functionality of Alteryx I managed to finish a few challenges during training (yesssss!). With a good start into Macros challenges and to solidify what we’ve learnt with Phil, I decided to finish off macros-related tasks.
If you don’t know what macros are and how to deal with them, Jon‘s giving a very short overview in his weekly recap, Sam‘s describing them in more detail in his post and this could be a good place to start. For our Friday project, we had to write macros with Tableau’s table calculations functionality (not gonna lie, taking up macros-related challenges came in quite handy…). As it turned out, the project was actually quite difficult and Alessandro described his experience with it while Robert found a solution to a problem we’ve encountered.
Alright, let’s get started. With some knowledge of macros, what do you need to finish the weekly challenges?
Know your challenge
I’ve said it already, and I’ll say it again. It is so important to know what you need to do in the challenge. I write down the key information and maybe the structure of the input and the desired output. From there, I try to figure out what has to be done to get the job done. I noticed I work faster once I’m aware what is needed from me (duh!).
Knowing what kind of transformations are necessary, I look into what kind of macro I should implement… (There are four types and they work in really different ways.) To find the right type of macro, it’s helpful to actually read the description of the challenge in the post on Alteryx Community, as they might hint what kind you should use.
Key differences between macros
Standard macro – nothing fancy, just a workflow wrapped as a macro. Can be dynamic and take arguments from the user.
Iterative macro – can be very useful especially when you want to update the same data set multiple times. A few things to keep in mind:
- input and output should have ideally the same structure
- you can use the iteration number as a variable in expressions (formula tool and other tools as well) – [Engine.IterationNumber]
- the iteration number starts at 0 and increments with every iteration (0-24 for 25 iterations)
- within the iterative macro the data set is still processed for all rows (I sometimes get confused and think it works only for one row at a time but that’s not true)
- iteration input and output need to be configured in Interface Designer, it’s also where you can change max number of iterations
Batch macro – quite a handy option if you want to repeat the same operation for a list of values. If a macro has a Control Parameter it’s a batch macro. What Phil suggested during the training, was to create a flow for a single value in the mentioned list, then figure out what needs to be changed to get the right outcome for the second value. Once that’s sorted, you should know how to adjust the flow to become actually dynamic and work properly.
I like to think of iterative macros as while-loops and batch macros as for-loops (if you have some programming experience, this should ring a bell, if you don’t, just ignore this).
The challenges themselves were sometimes super easy and sometimes very complicated. At least until I properly wrapped my head around them. Some were actually quite interesting math problems (nerd alert…) that I enjoyed figuring out how to represent in a math notation. This also helped a lot in creating then the right workflow.
There are some that build on previous challenges and it helps to do them chronologically, but I wouldn’t stress out too much about it.
That’s it for now… Go and have fun with macros and let me know how it goes. Also, hit me up if you have any problems. Who knows, maybe I’ll be able to help 😉