We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Dynamically ordering columns

RVDL
8 - Asteroid

Hi Community,

 

I have the following sample data:

 

IDTermValueCountry
A1Y1UK
A3M2UK
A2Y3UK
A2M4UK
A3Y5UK
B1Y6FR
B3M7FR
B2M8FR
B3Y9FR

 

I use a "Cross Tab" to create columns from the values found in column "Term" (note that 1Y is 1 year, 2M is 2 months, etc). I populate the columns with the values from column "Value". Thus I end up with:

IDCountry1Y2M2Y3M3Y
BFR68 79
AUK14325

 

I would like the table to show the columns in the following order:

ID2M3M1Y2Y3YCountry
B876 9FR
A42135UK

 

Thus the "Term" columns are ordered from shortest (2 month) to longest (3 year). And column "Country" is the last column. I can use a "Select" to set the order of the columns of course. But is there a way to do this dynamically? Thus if my data suddenly contains terms "1M" or "5Y" or whatever, it automatically allows for these new terms.

 

I can use a formula to map the terms to months: for example "2M" maps to 2, "3M" maps to 3, "1Y" maps to 12, ... and so on. But then what?

 

Thanks.

4 REPLIES 4
binuacs
21 - Polaris

@RVDL one way of doing this by converting the year into months

binuacs_1-1753465866314.png

 

Gaurav_Dhama_
12 - Quasar

Cross Tab places the columns in Ascending order, so easiest way that I work with, is by placing a number order before the column headers and the later drop it. Attaching a workflow to demonstrate the same. The second text input allows you to set the level by which you want to reorder your columns. Change the order in that and your columns will reorder automatically.

RVDL
8 - Asteroid

@binuacs 

@Gaurav_Dhama_ 

Thank you. Both solutions work fine.

flying008
15 - Aurora

Hi, @RVDL 

 

Another way for you:

 

录制_2025_07_29_08_48_03_161.gif

Labels
Top Solution Authors