Friday, 8 August 2014

Field Sort Macro

The below recently appeared on the Alteryx Community Ideas Forum:

"In my environment, creating tables with fields in a particular order is a requirement.

The Select tool (and others) let me manually change sort orders. The Select tool will also allow me to sort on Field Name in Ascending or Descending order.

I can add a sort order prefix to my input data with the Dynamic Rename tool, connect a Select tool and then go into the Select tool properties to sort by Field Name. But this requires that I first run the module so that the Select tool knows what the incoming fields are called, then set up the Select tool properties, and then rerun the module. If I change the prefixes or the list of incoming variables, the Select tool has to be reconfigured.

It would be really nice if there was a Field Sort tool that only had Ascending or Descending as properties that would 'dynamically' do what the Sort on Field Name option in the Select tool does."

It turns out that with a little inventive use of existing tools it is possible to do this today as a macro!

As with last weeks post if you want to challenge your Alteryx macro building skills then have a go at building this yourself before looking how I did it.

If you just want the macro to use or learn from, then you can download it here.