Alteryx Designer Discussions

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

Keep column header names in original order after Cross Tab tool

Number4
8 - Asteroid

I just wanted to post my solution to a problem which when searching for an answer, came up with too many responses that were more tool intensive.  There may be as good or better answers that I didn't see.

 

I have a data file that loads into a database, it does not come with column headers (B).
I have the table from the database where I can get the headers (A), using the Field Info tool.  But in order to use this, you have to use the Cross Tab tool which then puts the columns in the wrong order.  This is how I maintained the proper column order after the Cross Tab.

 

For the Cross Tab tool, change the column headers to the RecordID, with the name column being the new values data.

For the Union tool, use Auto Config by Position and make sure the Output Order is properly set.

For the Dynamic Rename tool, select 'Take Field Names from First Row of Data' from the drop down.

 

Tools Used

1. Top set of tools: Input (data base for me), Field Info, Record ID, Cross Tab.
2. Bottom set of tools: Input (txt file), Select (just because),  Multi-Field Formula (needed to remove a Tilde from each column).

Rows 1 and 2 are then brought into one using the Union tool, followed by the Dynamic Rename tool.

 

Col Hedrs_Crss Tb.JPG

 

Crss Tb Tool Config.JPG

2 REPLIES 2
apathetichell
16 - Nebula

This looks cool - but couldn't you use Union by position and get the same result?

Number4
8 - Asteroid

After using the Cross Tab tool, the header input is no longer in the same order as it was prior and thus not in the correct order as the data table.
If I Union them together as such, the data columns will get headers that don't apply to it.
A simple fix for this, would be to have the Cross Tab tool have a "leave unsorted" function built into it.

Labels