Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Create a workflow that reorders columns according to the header

NadaH
6 - Meteoroid

Hello everyone,

I am new on alteryx and I would like to create a workflow which reorders the columns regardless of the input file order.

if the input of the workflow corresponds to File 1 or File 2 the output should be the same

 

example :

Input File 1: E A B D C 

Input File 2:B D E A C

 

Output file should be : A B C D E 

 

Thank you in advance for your help

6 REPLIES 6
NickSm
Alteryx
Alteryx

Hi @NadaH ,

 

Would sorting headers alphabetically be a solution? If so, there is a "Sort Fields" tool in the CReW Macros pack which would be an easy one-tool fix. If not alphabetic, there are some other creative ways to define order.

 

For the CReW macros, you can download and install those tools in just a minute here:

 

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

NadaH
6 - Meteoroid

Thank you for your answer @NickSm ,
No, in my case the order of my columns should not be done alphabetically.

Can you give me some hints in this case?

 

Thanks

john_watkins
11 - Bolide

If both file inputs were fixed, you can use a Select Tool and click on the name of the field to auto-sort.  This will provide a one-time sort in either ascending or descending order and will at least minimize the clicking of the up-down arrow to do it manually.  If your inputs will vary, I second NickSm's response about using the Sort Fields tool for simplicity.

mceleavey
17 - Castor
17 - Castor

Hi @NadaH ,

 

I've attached a workflow that does this for you.

As you can see, I've created a file that determines the order of the columns. I then transpose the data, assign this order as a number, sort by that number, then crosstab back so the data is back in the original format but with the column in the correct order.

 

mceleavey_0-1623685953583.png

 

mceleavey_1-1623685977960.png

 

 

I hope this helps,

 

M.

 

 

 



Bulien

NadaH
6 - Meteoroid

@mceleavey Thank you

mceleavey
17 - Castor
17 - Castor

no problem.gif



Bulien

Labels