Alteryx Designer Desktop Discussions

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

Reorder columns based on header row

Carluccio555
9 - Comet

let’s say I have 20 fields in a specific left-to-right order, and the first record contains a unique identifier for each field.

 

How can I reorder the fields by reordering the first row unique identifiers?


So this is kind of like doing a join but based on fields instead of records.

 

I know I can do this with transpose/crosstab but was wondering if there is another way? 

8 REPLIES 8
PanPP
Alteryx Alumni (Retired)

Hi @Carluccio555 

 

I have attached a workflow that is similar to what I think you are describing.

 

One way to reorder columns is to use the select tool.

You can rearrange the sequence of the fields by selecting a field from the configuration window and then using the two arrows at the top.

 

Select tool.png

 

 

Hope this helps, if it does please like this post and if it helps resolve your problem, mark it as a solution. If you have any other questions, please let us know.

Adrian_T
Alteryx
Alteryx

Hi @Carluccio555,

 

Here is one way of doing it, sample workflow is attached. I used the Dynamic Rename Tool to temporarily swap first row data as column name, use the Select Tool to sort columns by ascending order, before renaming the columns again to the original column names.

 

Let me know if this helps!

 

Adrian_T_1-1670385116229.png

 

 

Carluccio555
9 - Comet

Thanks I will take a look when I’m at my desk.

 

For now, to clarify my question: 


The fields have a unique Id in record 1

 

eg. ID1, ID2, ID3

 

if I have a separate Text Input input tool with a single record as follows:

 

ID3, ID1, ID2

 

How can I effectively perform a SELECT action that outputs the fields in the order in the Text Input? If I wanted to ever change the order this would be done by changing the order in the Text Tool, not by using a SELECT tool

 

thanks 

 

PanPP
Alteryx Alumni (Retired)

You would have to use a sort tool to sort them in the proper order if they are in a single column.

 

If they are field names, you can move the column names using the up/down arrows.

Carluccio555
9 - Comet

Ok now I’ve realized I can probably just do this with a Union tool right? 😂

PanPP
Alteryx Alumni (Retired)

You can union the 2 datasets if you need to merge them eventually, then re-order the proper columns or records needed.

Carluccio555
9 - Comet

The text input exists only to set the order, it is a single record of the unique IDs reordered

 

Im not at my desk but I’m sure there’s a Union tool option that will Union the data to the text tool matching by field name, so effectively reordering by the text input. 

Adrian_T
Alteryx
Alteryx

Hey @Carluccio555, if that's the case, then yes a Union tool is all you require, configured to "Auto Config by Name". Remember to set the output order where the Template file is first in order so Alteryx takes your template header order.

 

Adrian_T_0-1670393935665.png

 

Adrian_T_1-1670394063823.png

 

 

Labels