In a previous post I shared how even a small tweak to a dataviz can change the perspective of the data story. The example I gave demonstrated how a view that used absolute time (with date defining the axis) presents a different story and highlights different insights versus a similar view that used relative time (age defining the axis). I also teased that I’d share a Tableau workbook some details around how the views were created. So, here it is!
(clicking a mark should navigate to that post, but you may need to enable pop-ups in your browser)
I encourage you to download the Tableau Public workbook above and you can deconstruct it to see how various views were created. And, I’ll also walk through some of the examples below.
Tableau DataViz #1: Absolute Time
This simple view shows a running total of page views for each blog post on VizPainter.com. You’ll notice that Pageviews was placed on the Rows shelf as an aggregate (SUM) and then a Quick Table Calculation was applied (Running Total). Date was dropped onto Columns and the Week date value option was selected from the drop-down. (by the way, if you struggle with the date options, as I used to, then check out “Dates in Tableau Make Me Want to Tear My Hair Out”). Post was dropped onto the Detail shelf so that you get a line for each individual post.
Now, it may look like a tangle of lines (there are a lot of posts!). It would be a great place to implement the data highlighter demonstrated at TC15. But until that feature drops, I’ll do a little cleanup:
The following steps are simply what I chose to do to highlight some of the posts. They are given as an example of what you might do:
- I filtered to the Top 15 Posts by SUM of Pageviews (dropped Post on Filter and selected the Top option)
- Moved Post to label. As a dimension it still slices the data, but now we can actually see what some of the lines represent.
- Edited the Pageviews axis (right click the axis and select Edit Axis) to set a fixed start of 0
- Edited the date axis (right click the axis and select Edit Axis) and removed the Title (it’s obviously a date) and fixed the end to a few months out to give the labels some room (this will have to change as new data is added):
- Format the date axis (right click the axis and select Format…) and changed the formatting on the Axis Scale to a custom string of mmm yyyy.
- Formatted the tooltips.
And, as previously noted, the view has some advantages when it comes to understanding when things happened based on an absolute date/time scale. But it is more difficult to compare the rate of growth because each line has its own starting place.
Tableau DataViz #2: Relative Time
One thing that has fascinated me for a while now is that a small change to an existing dataviz can reveal new perspectives and insights. Such is the case when we simply change the absolute date/time scale to a relative scale (the age of the post).
Now, it is a minor change to the view, but there are a few steps to take in Tableau:
- Create a calculated field that gives us the age of the post (I chose days as the unit). Here’s the code for Age of Post (days): MIN(DATEDIFF(‘day’, {FIXED [Post] : MIN([Date])}, [Date]))
You’ll notice the Level of Detail calculation (LOD calc) that returns the first date in the data for each Post and then the DATEDIFF that calculates the difference between that first date and the Date for each record of data. That gives us the age of each post for every date in the data. I chose to take a minimum of the results so that I wouldn’t double count when I have more than one record of data for a given post on a given date.
In the past, I might have used a table calculation instead of LOD calcs to index each point on the line and increment by one for each new date – but there are some drawbacks. The biggest problem is that any dates that are missing (yes, it’s hard to believe that there are some posts that don’t get visited each day!) won’t count for the table calculation – so the rate of growth for a given post might be skewed.
- I rearrange the fields in the view like this:
One important thing to note is that I have to ensure that the SUM(Pageviews) table calculation is specifically computed along Date instead of table across, since I’ve moved the Date field to the Detail shelf.
At this point, I really have a scatter plot – one point for each post and date based on its age and cumulative page views.
- Once I change the mark type to Line, I get a view like this:
I might once again choose to filter to clear out some clutter – or wait for the data highlighter widget. But even this view starts to tell a compelling story: how fast did posts grow in popularity?
Tableau DataViz #3: Relative Time Animated
I really like the ability to animate in Tableau. The Pages shelf is probably the most underused feature and yet it provides a very powerful storytelling ability. I think there are a couple of reasons for this:
- There are a few things not very intuitive about Pages and history (but I’ll try to clear them up here!)
- Animations cannot be automatically played on Server/Online/Public (anything in a browser). Maybe a future version will allow for this, but for now I’ll give a couple of alternatives.
With my view, animation allows me to bring the absolute date back into the picture and hints at some connections between posts that are not apparent in the static view.
Creating the animation is relatively easy:
- Copy the WEEK(Date) field from Detail to Pages (you can copy by holding CTRL while dragging and dropping).
Now we have some playback controls and the ability to step through or play through each week.
- But seeing a bunch of circles bounce around isn’t very helpful in this view, so I want to enable history. But when we look at the Show History controls on the playback menu, the ability to show previous marks or trails is not enabled.
Here’s a couple of tricks that aren’t very intuitive:
- Change the Mark Type to Circle. Why? Because only the marks for the current Page selection can ever be drawn. Lines don’t work because you need two points for a line but look at the view above: there’s only one point for each post on a given date. With the line mark type, Tableau draws a circle for that single point, but there are no previous marks to draw because the lines didn’t exist.
- Change the Marks to show history for to All.
- Now you can setup the Show History options to show Trails for All marks:
- Now you have a view that looks like this:
A few slight tweaks can really make it pop:
- Change the Color of the Marks to something bright and give it a border to make it really stand out:
- Finally, go back to the Show History controls and format your trails to be quite a bit lighter. For the animation, they are not the mail focus – but rather provide context.
- The workbook above demonstrates how I used a separate view to show the Month and Year. It also uses Week(Date) on the Pages Two views on a dashboard with the same field(s) on Pages can be synchronized (look for the option on the little caret dropdown of one of the playback control objects):
And now you have a view that gives even a slightly different perspective and tells its own story!
By the way, some people asked what I used to capture the animation. I used Camtasia. Wouldn’t it be great to export animated gifs directly from Tableau without using a 3rd party tool? If you’d like to see this feature, then you might vote up this idea: Allow export of animated gif from Pages shelf animation
Best Regards,
Joshua
This is an amazing viz and just what I am looking for.
Thanks James!