Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #63: Data Preperation Using Pivot Tools

JoeM
Alteryx Alumni (Retired)

The solution to last week's challenge can be found HERE.

 

If you have even been shy about getting to know the crosstab/pivot tools, this challenge will serve as an excellent guide to becoming better acquainted with the tools.

 

An organization receives an input file like this every month or so.  Additional columns are added to the file each time, representing data for more weeks.  They need a workflow that will pivot the data so that each week end date is included on a row for each DMA number in column 1.  The workflow needs to allow for the fact that additional columns will be included in later months.

patrick_digan
17 - Castor
17 - Castor

@JoeM I look forward to someone else providing a much slicker solution. My methods are not fancy, but they do work. I made use of a generic macro I use, so I've included it in my yxzp file.

 

Spoiler
I first selected the relevant rows of data with a select records tool. I "Excel Transposed" the data which is a simple macro I created a while back to carefully transpose and then crosstab the data to match excel's paste special transpose option. I used a formula tool to get the dates formatted, a multi-row formula tool to fill in missing dates, and a formula tool to get the column heading for the total row. I then used a transpose crosstab combo to re-orient the data back. 
Capture.PNG
MarqueeCrew
20 - Arcturus
20 - Arcturus

@patrick_digan,

 

Slick?  I think not.  I did take a different tact than you did.  I don't use the select records tool often (and I still didn't), so thanks for the reminder.  I ran into several bumps in the road:

  • The last column only has data for Inside Sales (Outside & Total Sales columns are not present)
  • The general unhappiness of spaces & special characters when using the crosstab tool.

My approach was more lengthy than yours was.  I didn't run yours, but I did test my output against @JoeM's output where I got identical results.

 

When working with clients and prospects I often get Excel "Reports" that need to be converted to DATA before real analytics can be executed.  This often is time consuming.  This challenge was work for me.  I beat it into submission.

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
alex
11 - Bolide

I didn't provide much documentation on this one, but it should be fairly easy to follow if you download the workflow.  I tested it by adding a new column and amounts to make sure it would handle new columns.  Worked as expected. @patrick_digan - I'll have to check out your macro when I have time.63-2.JPG

Spoiler
63-2.JPG
alex
11 - Bolide

For extra credit I'll post my first attempt at this solution with no documentation.  In this version I kept the input file that I added an additional column to.  Still works and slightly faster than my previous posted solution.  Why does cross tab tool add underscores to column headings?  Thanks for the challenging exercise @JoeM

 

Spoiler
63-A.JPG
Natasha
9 - Comet

My solution is definitely not concise but I got to the required output. Looking forward to inspect other's neat solutions :)

 

Spoiler
Screen Shot 2017-03-27 at 20.37.00.png
NicoleJohnson
ACE Emeritus
ACE Emeritus

Solution attached. Most similar to one of Alex's solutions, I believe.

 

However, I think I also uncovered an issue with the output results as posted in the original workflow - in the case where there was not both an Inside & Outside sales column, therefore no Total Sales column for that week (in this example, week 2016-04-24), then the Total amount for that week was showing as zero in the posted output results, despite there being an amount for Inside sales. So I added a formula at the end to check to see if Inside POS + Outside POS = Total POS... if it didn't, then I replaced the Total POS value with Inside POS + Outside POS. Which is also a good check in case someone posted the wrong value in Total POS to begin with.

 

Hope this helps! :)

 

Spoiler
WeeklyChallenge63.JPG

 

alex
11 - Bolide

@NicoleJohnsonNice auditing work!  I checked my results against the answer, but did not check the answer itself.

pvara
8 - Asteroid

Hi Nicole can you please repost your alteryx solution? The link points to some XML file. Thank you.

JoeM
Alteryx Alumni (Retired)

 @pvara, I had no issues downloading. Is your machine's default program from XML notepad or a similar program? Does the downloaded file show as .yxmd?