Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Help with macro controlling Sort By fields

csh8428
11 - Bolide

I have a macro where I want to be able to control the which fields are the "Sort By" fields as well as the Order of said fields.(attached)

The fields going into the macro are dynamic so the field names are not known and it could have 1 sort by field, 2 sort by, or more.

 

Thanks for any help!!

 

Craig

5 REPLIES 5
caltang
17 - Castor
17 - Castor

So, basically you're trying to make a dynamic sort based on new fields entering the data, right?

 

Can you provide some additional sample data and what your desired output would look like? You can use Excel to showcase this idea, then we can go from there.

 

P.S, connecting the input with the list box may not yield the result you want. If you use file interface + the list box, then you can see the active list of fields via analytic app. It would help to use chain apps if you're going the analytical app route to make it easier to build.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
csh8428
11 - Bolide

@caltang Yes trying to make a dynamic sort OF THE FIELD NAMES.. not the data. I want to be able to pick which fields get sorted and which fields "stay" at the beginning and not alphabetized(ID fields for example). I've attached a sample dataset with 2 examples of differing numbers of ID fields along with a screenshot of the same dataset. Put another way, i am being given a data-set where the columns are completely out of order and I want to be able to choose which fields to "keep" at the beginning and which fields get alphabetized. The number of "ID" fields to keep at the beginning changes depending on which data-set I'm being given.sample.png

aatalai
14 - Magnetar

@csh8428 look at the crew macros 

 

http://www.chaosreignswithin.com/p/macros.html

 

There is a field sort tool already that might be able to help

 

field sort.PNG

csh8428
11 - Bolide

@aatalai While that macro does work(I already tried it), it doesn't satisfy my requirement of being able to dynamically select which fields "stay" at the beginning.

caltang
17 - Castor
17 - Castor

Well, not a macro per se but an analytic app that showcases the selection capability as per your request.

 

Because you want to see what fields are in your data, you'll need to get it to connect with the file input interface. A macro itself is not able to show you the field values "live" unless you use control containers I believe. Even then it gets complex with interface tools - I've not tried that yet.

 

But I offer you an alternative approach via analytical apps. It allows you two ways, one to sort ascending/descending on the field names as is. Two is that it allows you to retain x number of fields in their original position from the dataset at the front of the fields, then sort the rest ascending/descending to your liking. 

 

image.png

 

I've left the annotations inside and you can study the interface interactions.

 

P.S: Yeah I get the fact that you need to sort the FIELD NAMES, but once you pivot your field names for sorting etc via Transpose/Cross Tab or Field Info tools, your field names become your data. Then you can pivot it back and use a neat trick on the Union tool like so:

 

image.png

 

This configuration follows the order of your 1st input in Union, so your following inputs are forced to follow the field name order.

 

It's not exactly the macro you wanted, but it solves the need. You can replace the Browse tools with your ETL processes thereafter. Hope this helps.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
Labels
Top Solution Authors