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 new columns based on current headers

Phurphur
5 - Atom

The problem I am having is I need to create an Excel output that would require the least amount of work I would need to do to have it set up and ready for distribution.  The request is to create a column prior to another column that will be filled with the question in the header for each row (see example below).  The issue is that this needs to be ran multiple times weekly, the questions will be different each time it is run, as will the number of questions for each run so it will need to dynamically determine how many questions there are.

 

The original file will always be set up the same way with Name being the first column, and followed by ONLY questions for each of the other columns such as this:

 

NameWhat Number?What Letter?
Justin1B
Matt4E
Michael6J

 

The output will need to skip the first column (Name) but then insert a new column to the left of the answers that uses the header as the fill, so that each row on its own will contain the question as well as the answers.  The headers for the new columns will always start with 'Question " and be sequential from left to right starting at one, going to right through however many questions there are.  This may range from 2 to 30, so creating formulas every time I get this file has become laborious as the column headers are always the question being asked and I cannot reuse the workflows from file to file.  The output should look like this for the above example:

 

NameQuestion 1What Number?Question 2What Letter?
JustinWhat Number?1What Letter?B
MattWhat Number?4What Letter?E
MichaelWhat Number?6What Letter?J

 

I have been able to create a header row that has all the correct column names, but cannot figure out how to get the data in it correctly and I also feel that my experiment was unaturally complicated!  LOL.  Help would be greatly appreciated.  Thank you.

5 REPLIES 5
Felipe_Ribeir0
16 - Nebula

Hi @Phurphur 

 

One way of doing this:

 

transpose.png

Phurphur
5 - Atom

Thank you for this solution, but do you know how to keep the question number columns next to the correct column?  If I have 20 columns, I am trying to keep the amount of manual work down as much as possible.  I love this solution though!  I will use it if there is no way to keep the columns in an order.  Thank you!

Felipe_Ribeir0
16 - Nebula

Hi @Phurphur 

 

Unfortunately, keeping the order dynamically like you want is tricky for this case using Alteryx. I do not know a way to do it right now, will think a little more and if i find a way, i tell you here.

Felipe_Ribeir0
16 - Nebula

Hi @Phurphur 

 

Found a way around, please take a look.

Phurphur
5 - Atom

Perfect!  Thanks again!

Labels