Alteryx Designer Desktop Discussions

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

Data Transformation - Crosstab / Transpose

vinakota
6 - Meteoroid

Dear Alteryx Community

 

I am a newbie to the tool and needed some help. I have a specified input data format that I am looking to transform to a specified output data format. I have attached the sample file here for your reference. I appreciate any examples/suggestions that the community may be able to share. 

 

Input

 

Time PeriodActual DemandYour ForecastAPEMAPE (%)Paricipant IDFile Name
T1505   12345678ABC
T2493   12345678ABC
T3521   12345678ABC
T4504   12345678ABC
T5547   12345678ABC
T65015400.0778443110.07784431112345678ABC
T75314990.0602636530.06905398212345678ABC
T85435200.0423572740.0601550812345678ABC
T95405250.0277777780.05206075412345678ABC
T105495300.0346083790.04857027912345678ABC
T1542   12345679ABD
T2482   12345679ABD
T3482   12345679ABD
T4533   12345679ABD
T5488   12345679ABD
T64925400.0975609760.09756097612345679ABD
T74805000.0416666670.06961382112345679ABD
T84934900.0060851930.04843761212345679ABD
T95224800.080459770.05644315112345679ABD
T105235000.0439770550.05394993212345679ABD

 

Output

 

Paricipant IDFile_NameT6_Actual DemandT7_Actual DemandT8_Actual DemandT9_Actual DemandT10_Actual DemandT6_Your ForecastT7_Your ForecastT8_Your ForecastT9_Your ForecastT10_Your Forecast
12345678ABC501531543540549540499520525530
12345679ABD          
12345680ABE          
3 REPLIES 3
SPetrie
13 - Pulsar

You just need to cleanup the data and do a bit of prep for the final column headers. 

I removed the extra columns since it doesnt look like they are used in your example output. I also got rid of any rows that didnt have a Forecast since it looks like those are not in the final output either.

I do a transpose to get them lined up vertically and then use a formula to combine the time period with the original column name to get the new output headers. I also added the first letter of the name at the beginning of the new name to get a better sorting after the crosstab.

After crosstab, I use a dynamic rename to remove the extra bit I put on front to get the final output.

 

 

SPetrie_1-1660707402397.png

SPetrie_4-1660707705837.png

SPetrie_5-1660707776834.png

 

 

 

This is what the sorting would look like after cross tab if I didnt add the extra bit to the new name first.

SPetrie_3-1660707562728.png

You could rearrange them with a select tool later, but the method I used forces a better alphabetical sorting so you dont have to worry about it later on if fields get added/changed.

Im sure there is an easier way of doing it but Im too lazy to look it up at the moment :)

 

vinakota
6 - Meteoroid

Very helpful and exactly what I needed. Thank you... 

 

Just some advise.. If I have to create calculation based on forecast and the demand for each period,do you suggest creating them first in excel and then transposing in Alteryx or can I perform them in alteryx directly? 

 

Regards,

Srikant.

SPetrie
13 - Pulsar

Its up to you. You can do them in excel first or directly in Alteryx with the formula tool. If you do it in Alteryx, put it in before the transpose and it should bring in the new field for the output.

SPetrie_0-1660755816972.png

SPetrie_1-1660755896110.png

 

 

Labels
Top Solution Authors