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

Engine Works Blog

Under the hood of Alteryx: tips, tricks and how-to's.
Alteryx Alumni (Retired)

Ah, the simple joys of the Sample tool. It has to be one of the easiest tools in Alteryx for new users to grasp. I know for myself, it is a frequently used method of selecting exactly the records I wish to work with. While this can often be accomplished by more flexible means, such as the Filter tool, the Sample tool affords a rapid simplicity that is always close at hand.

 

After a while, I soon found myself using this tool twice in a row... The first allowed me to skip a specified number of records, while the second allowed me select records from the top of the new list. Thus, I was able to choose a range of records from within the original dataset, and not merely at the beginning or end as the use of just one Sample tool would limit you to.

 

 

Going a step further, there were times when I wanted this "range", and times when I wanted everything but those records in my "range". Phew, this soon added up to quite a few tools, and while not too complex to set up in a module, it started to feel like a lot of work. And of course, any change that needed to be made to the desired range of records required the properties of no less than 4 Sample tools to be altered. The warning lights flashed, bells chimed, and sound of thunder was not far in the offing, it was time for a Macro!

 

 

As with all Macros, it is best to think of their development as an investment. Fine craftsman are renowned for using tools to make more tools that allow them to make stuff (yes, that is the technical term). With Alteryx, the analogy holds true, we just allow craftsman to make business decisions instead of 'stuff'... Presented here is the Sample Range tool, a Macro that allows the user to specify a range of records to sample upon. In an effort to kick things up a notch, this Macro has two outputs, the first delivers records that were defined by our range, the second provides all of the records except those specified by the range.

 

Setting up the Sample Range tool is quite simple, a beginning and end value for the range is all that is necessary.

 

If you think this tool would be a useful addition to your Toolbox, simply save the "SampleRange.yxmc" (found here) file to the following location on your machine (assuming you are 64bit). The Sample Range tool will then be added to the Macros drawer of your Toolbox.

 

C:\Program Files\Alteryx\2011\Engine\RuntimeData\Macros

 

Enjoy!

Brett Gottdener

Labels