community
cancel
Showing results for 
Search instead for 
Did you mean: 
Do you have the skills to make it to the top? Subscribe to our weekly challenges. Try your best to solve the problem, share your solution, and see how others tackled the same problem. We share our answer too.
Weekly Challenge
Do you have the skills to make it to the top? Subscribe to our weekly challenges. Try your best to solve the problem, share your solution, and see how others tackled the same problem. We share our answer too.
Unable to display your progress at this time. Please try again a little later, or contact an administrator if you continue to see this error.
Announcement | Get certified today - take the Alteryx Designer Core and Advanced exams on-demand now!

Challenge #63: Data Preperation Using Pivot Tools

Director, Customer Enablement
Director, Customer Enablement

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.

Highlighted

@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
Alteryx Certified Partner
Alteryx Certified Partner

@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 reboot. Order shall return.
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
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
Alteryx Certified Partner

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

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

 

Bolide

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

Asteroid

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

Director, Customer Enablement
Director, Customer Enablement

 @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?