In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
ned_blog
8 - Asteroid

I have gotten the question of how to count records in a stream. The simplistic answer is to use a summarize tool. That works in most situations, but the summarize tool doesn't output any records if no records come in. It does seem like a valid request to be able to get a 0 count of records, because you might want to put something on a report that says "N Unmatched Records" and sometimes N is 0 and you want to know about it. After being asked 1 more time, I decided to throw together a simple macro to do it. You can find it in Alteryx post v 5.0.

 

How does it work? Very simple.

 

The macro takes your input and then runs a summarize tool. It also has text input that supplies the count of 0. I union together the count from the summarize & the text tool and then take the 1st record. If the count is >0 than the summarize tool produces a record and that is the one that is output. If there are no records coming in, then the dummy record showing the 0 count from the text tool gets output. Either way the macro outputs a record, even if there were none in the input. Another good example of how powerful macros can be - even simple ones.

Comments