In this series of blog posts, I will be featuring an individual Alteryx tool to break down and sing its praises. I will be picking tools at my own discretion, but if there is a tool you’d like me to spotlight, shoot me an email: tmccoy at alteryx.com. I will want to know why you are asking for a particular tool, but I will be happy to write about it.
In this post I will be focusing on the Sample tool, a handy little guy whose sole purpose in life is to return a little nugget of records from your data stream. Maybe you want to test your sample of records for troubleshooting your module, refine your process, or isolate specific records. Maybe you want to pick a random winner of a prize, as we do from time to time. For all the reasons you might want to use it, the Sample tool is as handy as it is smart, and designed to optimize your module in some pretty clever ways.
The configuration of the Sample tool is quite simple. You just pick how many records you want to come out of the tool and from what position of the incoming stream. You can also apply this to Groups – i.e. I want my first 10 customers for each store.
A very cool feature of the Sample tool is the fact that it will actually stop tools upstream from processing once it receives the records it needs. Of course it only does this in one mode: “First N Records,” as all other modes require a read through the entire stream to return the sample.
Another feature of the Sample tool is to return a random sample of records from your data. A truly random sample means you will get a variable count of records at run time. If you are looking for a more deterministic output, try the Random n[%] of Records Macro in the Macro tool category.
This Macro assigns a random number to each incoming record via a formula tool, sorts on that field and then returns the number of records you want out of it. It will run in deterministic mode where you specify a seed and you’ll get the same records out each time.
If you have placed a Sample tool in your module as a temporary tactic of scaling back your data while you make improvements to your module, you can easily remove it when done by right clicking on the tool and choosing, “Delete and Connect Around.”
So there you go, the Sample tool gets its 15 minutes of fame this week in the spotlight.