Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

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

Multi-level Pivot Table - Crosstab 2 column header not possible

thuyduongnguyen
7 - Meteor

Dear Alteryx community,

To create an output just like Pivot table in Excel (with 2 fields on Column), I have search many posts about Crosstab and Transpose to try out but haven't succeeded yet.

Crosstab tool is great but it doesn't support more than 1 column header.

 

Input:

LocationYearQuarterNewCloseSum
A2019Q11-10
A2019Q21-10
A2019Q31-10
A2019Q41-10
B2019Q110-19
B2019Q210-19
B2019Q310-19
B2019Q410-19
A2020Q12-11
A2020Q22-11
A2020Q32-11
A2020Q42-11
B2020Q120-119
B2020Q220-119
B2020Q320-119
B2020Q420-119

 

Expected Output: (2 different tables can be saved in one Sheet).

I will use these table to create charts in Excel for each location, so this format need to be kept this way.

 20192019201920192020202020202020
AQ1Q2Q3Q4Q1Q2Q3Q4
New11112222
Close-1-1-1-1-1-1-1-1
Sum00001111

 

 20192019201920192020202020202020
BQ1Q2Q3Q4Q1Q2Q3Q4
New1010101020202020
Close-1-1-1-1-1-1-1-1
Sum999919191919

 

I appreciate every suggestion or work-around solution for this to work.

Thank you very much and Best Regards,

Duong 

2 REPLIES 2
AngelosPachis
16 - Nebula

Hi @thuyduongnguyen ,

 

I've mocked up a workflow for you that I think achieves what you are looking for. The output is an excel file that looks something like that

 

AngelosPachis_0-1610113443550.png

 

and it's in the same sheet of an excel file.

 

The workflow is this:

AngelosPachis_2-1610113633354.png

 

 

which transposes and cross-tabs the data till it brings them to the required format. Then I have created a separate field, which assigns a row ID to maintain the sequence that your records will appear (Quarter>New>Close>Sum)

 

Finally, to force both tables in the same excel sheet in the desired format, you have to play with the reporting tools, or just use an output data tool.

 

Hope that helps,

 

Regards,

 

Angelos

 

 

thuyduongnguyen
7 - Meteor

Thank you very much for your suggestion!

I have tried and it works perfect for my case.

 

Only a small modification:

I also choose [Year] in Data Columns of Transpose tool, so in the end I can use Output Data tool instead of manual adjusting column name if using Basic Table tool. 

Labels