Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

How to have Data Appended in a Row After Cross-Tab

rishipatel3
5 - Atom

In my current Alteryx workflow, I used the cross tab function to have by data broken out by columns rather that rows. For instance, say the data was:

 

 JanuaryFebMarch
Candy121
Sports Drinks345
Snacks432

 

Instead, I wanted to see the data as such:

 CandySports DrinksSnacks
January134
Feb243
March152

 

I have been able to do that successfully through the cross-tab tool, but here is the issue I am facing. Another report I want to compare it against, orders their inventory differently, and so the second report may show the headers as: "Snacks, Sports Drinks, Candy".

 

The order of the second report is consistent and I have a sheet with the Column Number that each inventory item should belong in. So what I need help doing is:

1) Figuring out how I can insert a blank row into my data after the Cross-tab

2) Essentially VLOOKUP what column number each inventory item belongs in (this column number would go into the blank cell I created in the row under neath the header)

3) Horizontally sort the data so that the order is ascending

 

Does anyone have any ideas? Thank you all in advance.

6 REPLIES 6
john_miller9
11 - Bolide

@rishipatel3 

 

If I understand correctly, you are looking to compare inventory of two separate reports that have both a month and category dimension.  If that's correct, I'd suggest doing the comparison with transformed, tall data, rather then comparing cross-tabs.  What exactly are you trying to determine (e.g. how much more/less inventory #1 is compared to inventory #2 for a given month/category)?  

JosephSerpis
17 - Castor
17 - Castor

Hi @rishipatel3 I mocked up something I think you are asking for. Union.JPG

rishipatel3
5 - Atom

So I need to utilize the cross-tab because I need the data broken out over multiple columns rather than multiple rows for each month. The system used to present the data this way, and so all of the rest of the processes are based on this format.

rishipatel3
5 - Atom

Hey! Thanks for building out the mock-up. Unfortunately, I was envisioning something a little different. So more so imagine in that blank row you inserted, I was to pull in the column number that I want each column to be, so that if I sorted the data based on that row, it would reorder. I know the wording is a little unclear, it's just not as easy to verbally state. Let's try this:

 

This is my data as of right now:

 CandyPoweradeGushersTwixGatorade
January13423
Feb24323
March15213

 

I have a second sheet that looks like this:

Candy4
Powerade2
Gatorade1
Twix5
Gushers3

 

I want to first add a row so my data looks like this:

 CandyPoweradeGushersTwixGatorade
      
January13423
Feb24323
March15213

 

Then I want to pull in the column numbers into that blank row:

 CandyPoweradeGushersTwixGatorade
 42351
January13423
Feb24323
March15213

 

Then I need to sort that row with the column numbers in ascending order:

 GatoradePoweradeGushersCandyTwix
 12345
January33412
Feb34322
March35211

 

Does that help visually show what I'm trying to do? The data I am working with is hundreds of columns, so I have to try and streamline the process the best I can.

john_miller9
11 - Bolide

@rishipatel3 

 

See if the attached is what you are looking for.  The "Data Sort Order" data source is what you would use to re-order the "Input Data" data source.

 

Edit: Updated to sort by month as well

Sort Cross Tab Data.png

estherb47
15 - Aurora
15 - Aurora

Hi @rishipatel3 

 

No need to add the extra row to set the order, you can do this within a few tools.

 

You have the order of the fields in the second table, so we just need a way to assign those to the item. By transposing your first table, then changing the field size to a bit larger with a Select tool, you can join that number in. A formula tool prepends the number to the field name, and then a crosstab tool rebuilds your table, with everything in the correct order.

 

Finally, a dynamic rename tool, using a formula to rename all of the fields:

regex_replace([_CurrentField_],"\d+(.*)","$1")

image.png

 

Let me know if that helps.

 

Cheers!

Esther

 

 

Labels
Top Solution Authors