May 24, 2012

Creating an interactive monthly calendar in Tableau is easier than you might think

If you’re not following the InterWorks blog, you should be.  They routinely crank out fantastic tips and tricks for Tableau.  Dustin Wyers, a BI Analyst for InterWorks, recently wrote about “Creating Calendar Views in Tableau”. 

Dustin’s post does an excellent job of taking you through creating a calendar viz step-by-step.  But I felt it fell a bit short in the end since you didn’t actually see a calendar.  Dustin’s end product looks like this:
Interworks Calendar
I wanted something that looked more like a true calendar.  I did so utilizing some of the techniques I outlined recently for creating a heat map, but also adding in some of the suggestions by Joe Mako.  The end result, if you follow the tutorial below, will look like this:

image

Ok, let’s get to it.

Step 1 – Create a list of dates in Excel and open the data in Tableau.

image

Step 2 – Right-click drag the Date field onto the Column shelf and choose the MY(Date) discrete format

image

Your view should look like this:

image

Step 3 - Right-click drag the Date field onto the Column shelf and choose the WEEKDAY(Date) discrete format

image

Your view should look like this:

image

Step 4 - Right-click drag the Date field onto the Row shelf and choose the WEEK(Date) discrete format

image

Your view should look like this:

image

Step 5 – Clean up the view a bit by right-clicking on the Date label and choosing Hide Field Labels for Columns

image

Step 6 – Right-click on the WEEK(Date) pill on the Rows shelf and uncheck Show Header

image

Your view should look like this:

image

We’re getting close! 

Step 7 – Right-click drag the Date field onto the Text shelf and choose DAY(Date)

image

Step 8 – Align the Text to the top right, center the header for the WEEKDAY(Date (copy) field, re-size the view a bit and we now have a beautiful calendar.

image

Ok, sweet, we have something that looks exactly like a calendar, but so what?  This doesn’t tell us anything. 

Consider that you want to see the profit ratio for your sales (or any other metric) displayed on each day as a color.  This is where data blending comes in handy. 

Step 9 – Connect to the Superstore Sales data source (or any other data you want to use, as long as it has a date field)

You might ask at this point why I used a separate data source for the calendar dates when a Date field exists in the Superstore Sales data.  The reason is quite simple.  The Superstore Sales data does not have sales for every day.  Therefore I will not see the Day labels on each of the boxes.  For example, if there are no sales on January 13, 2009, then the 13 label on that day will be blank.

Step 10 – Create the data blending relationships.  Go to the Data menu and choose Edit Relationships.  You will need to create these Custom relationships:

image

Step 11 – Create a calculation for Profit Ratio by right-clicking on any field and choosing Create Calculated Field

image

Step 12 – Drag the Profit Ratio measure onto the Color shelf

Step 13 – Change the Mark Type to Square

Step 14 – Set the size to its maximum

image

That’s it!  You must admit this is pretty cool. 

Note that Tableau defaults positive and negative colors to the Red-Green palette; you might want to change it for those color blind folks out there (and to keep Steve Wexler off your back).

If you want to take it a couple steps farther, you could show the quick filter for the MY(Date) field, create a parameter to allow for any of several metrics to be chosen, and on an on to make it a truly interactive analysis.

In the version embedded below, I changed the color palette to Red-White-Green so that those days without any sales would be white instead of gray.

Try this with your own data.  I bet your users will find this incredibly useful, especially as a performance monitoring tool.