Engine Works

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

The other day, a feature request came in for making the formula tool into an input tool - i.e. not requiring that an input goes into the tool. I didn't understand why someone would want to do this so after some digging I found out that they just wanted to get the DateTimeNow() out into a stream. You can do this with 2 tools, or even 1 tool with a generate rows, but the requestor thought that was too much. My answer was to just write a macro, because we don't need a whole new feature to do this. It took only a few minutes to write the macro, but then I thought I'd generalize it and add a pull down for what format you want the date/time in.

 

This worked beautifully until I started testing. I was just using a manual list in a pull down and all the format's that had a : in them were broken. This is because the manual input uses the colon to delimitate between the descriptive name and the value. There wasn't any way to escape a colon. I could have used a separate file for the values in the pull down, but I wanted to keep it simple. I could have changed the code to make this work for me, but then the macro would require a new version of Alteryx. So I went digging in Unicode and found another character (0x2D0) that looks just like a colon: ? If you look closely you will see that it has triangles instead of circles, but I figured no one would notice that at a small font size. So anyway I fixed up the list and everything works great. If interested, you can find the macro in Alteryx.