Overview
You can download a trial version of Alteryx here.
You can find the Excel source data here.
You can download the completed Alteryx module from here.
Understanding the workflow
Here’s the Alteryx workflow that will get the data in the format we want.
If this is the first time you’ve seen an Alteryx workflow it may look a little complicated (shades of Rube Goldberg) but think about how complicated the flow and decision tree is for what you do when you get up in the morning and get ready for work – it’s way more complicated.
Let’s start by focusing on the three data sources that we need (labeled 1, 2, and 3 in the diagram above).
- Data with numeric responses (we’ll use this for our demographic data, too)
- Data with text responses
- The Question Helper file (contains our meta data).
A note about SPSS files
For this example we’re using Excel data but the process would be identical for survey data saved in an SPSS format (.SAV file). SPSS encodes both the text and numeric data in a single file, but you need to input values from that same data source twice – once for text and once for numeric values.
When you specify an SPSS file as a data source you’ll see the following check box option.
Selecting “Expand Factors” will bring in the data as labels. Unchecking this box will bring in the data as numbers.
Demographics
Clicking the Select tool reveals the following settings.
A translation into English would be “open this Excel file and select these fields”. Here we keep RespID, Gender, Location, Generation, and Weight.
Numeric values
Using the same data source, selecting the Transpose tool reveals the following settings.
Here we indicate that we want to keep RespID and pivot all the other checked fields. Notice that the demographic components are not checked.
Looking back to the workflow diagram, we next follow this pivot with a Select tool which we use to rename the pivoted fields as shown here.
Here we are naming the first pivoted field Question ID and the second pivoted field Numeric value.
Dealing with nulls
While not critical, Alteryx allows us to eliminate null values before they come into Tableau. Here’s the setting for this tool.
Joining the demographic with the transposed (pivoted) numeric data
We’re now ready to join the demographic data with the pivoted numeric survey data. We do this with Alteryx’s Join tool. Here are the settings.
Checking our progress
If we add a Browse tool after the Join we’ll see the following results.
Note that we could, in fact, get by with using just this in Tableau, but the whole point is to make things faster and easier, so we’re going to add text responses and the “Helper” data.
Text Values
This is identical to the numeric values except that we specify a different data source (one with label responses instead of numeric) and we rename the second pivoted field differently, as shown here.
Here we are naming the first pivoted field Question ID and the second Text value.
Tying Demographic, Numeric and Text Values Together
We need to combine the demographic / numeric values with the text values. We will again use Alteryx’s Join tool, but we’ll need to join on both RespID and Question ID.
The setting for the Join is shown below.
Adding the question meta data and outputting the results
We’re almost done; we just need to add the information that tells us about each Question ID so we can map the ID to its human-readable form, group related IDs together, and so on.
The setting for this Join is shown below.
The only thing left to do is output this to a new data source. In the sample workflow I output to an Excel file but you can just as easily write directly to a Tableau Data Extract file.
But Wait! There’s More!
I intentionally used data that was well behaved, but what happens if the data is “messy”? For example, suppose there’s an extra row below the field names? Or suppose that for a check-all-that-apply question, instead of 1s and 0s we instead have 1s and blanks (which would mess things up in Tableau)? Alteryx handles both of these scenarios (and dozens more) easily.
Is there a Downside?
If there’s any downside it would be the cost as Alteryx starts at around $4,000 per year. If all you are doing is some occasional survey data reshaping then this fee would probably be prohibitively expensive. If, however, you need to corral a lot of data – or if you need advanced data blending, geospatial analysis, or predictive modeling – then Alteryx is a huge bargain.