Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
6 - Meteoroid

I had the pleasure of helping test a module for the Alteryx Grand Prix and learned a number of things. But the most interesting? Mod.





Wikipedia gives you many options for mod, including the "1960s British youth subculture." Not sure how that applies to Alteryx I kept scrolling. Aha! Modular arithmetic - that's more like it.


A familiar use of modular arithmetic is its use in the 12-hour clock: the arithmetic of time-keeping in which the day is divided into two 12 hour periods. If the time is 7:00 now, then 8 hours later it will be 3:00. Usual addition would suggest that the later time should be 7 + 8 = 15, but this is not the answer because clock time "wraps around" every 12 hours; there is no "15 o'clock". Likewise, if the clock starts at 12:00 (noon) and 21 hours elapse, then the time will be 9:00 the next day, rather than 33:00. Since the hour number starts over when it reaches 12, this is arithmetic modulo 12.


We used the mod function in Alteryx (found in Math -> Integer) to group records together. There was a pattern in the records where every 3rd record contained header information for it and the next two rows (the data had to be sorted to see the pattern).

Group = Mod([RecordID], 3)


This resulted in the records having a Group value of 1, 2 or 0. The values wrapped around on every third row. Using those group values we did some additional grouping and then summarizing (I don't want to give away the solution!).


I've already found a use for mod in a client's project I am working on. Their data is week based. Using mod I'll be able to group the weeks for analysis. I've done it another way already which required multiple MulitFieldFormula tools. Mod is going to simplify my module greatly.


Too bad our mod doesn't come with customized scooter like the mod kids in the picture have.