Wednesday, 25 November 2015

Approval Ratings of US Senators

Quick political disclaimer - I think Bernie Sanders should be the next US President, even though I don't get a vote....

I recently came across this article on Morning Consult showing the results of a recent poll that placed Bernie Sanders as the US Senator with highest within State approval rating. I wanted to skim the results of the survey, but unfortunately they were presented in a pretty boring way that made it hard to quickly navigate and explore. I thought I could probably do a better job.

And so I came up with this

Now the hex-bin map is something I've been wanting to try, and thanks to both Matt Chambers and Brittany Fong for their recent instructional blog posts on how to do this. I wanted to use Matt's technique, and he kindly provides some clear instructions and base data to copy. Definitely read his post to understand what I'm doing below.

But because there are two senators per state, I needed to split up the hexagons. To do this I created both a left and a right half-hexagon, using powerpoint as my tool, and placed each in the Tableau Shape File repository. I was going to re-color the shapes in Tableau anyway so don't worry about the shades below.

And I needed to adjust the positioning of each half of the state, so I nudged one half left and one half right a bit.

See how my column field includes values 0.25 away from the centre of where the hex's will be placed?

Lastly, I wanted to use Net Promoter Score because I didn't think the straight approval rating tells the whole story. And as you know I can't resist throwing in a URL picture.

Feedback welcome, and feel free to use this technique for any Senate related vizzes in future!

Monday, 9 November 2015

Let's put some things into context - a practical introduction to Context Filters in Tableau

One piece of functionality in Tableau that I've been using a lot recently, and that people have been asking me about are CONTEXT FILTERS. They seem to cause quite a bit of confusion for new Tableau users so I thought I'd try and write a blog post showing some of the ways in which they can be utilized. This should also help me get a firmer grip on them myself, as I too find knowing when to use them isn't always straight forward.

Now what I'm not going to do here is talk about Context Filters in terms of performance. My experience with using context filters to improve performance is very hit and miss, sometimes it works, sometimes it slows things down and sometimes there is no difference. This all depends on your data connection type, the size and width of your data and what you are trying to achieve with the filter. For improving performance with context filters I suggest you utilise the ever popular 'try it and see' approach. I am going to talk about Context Filters in terms of functionality and give some examples.

First up, how do I make a regular filter a Context Filter?

This one's easy - you simply right click on your filter pill (or click the drop down arrow) and select 'Add to Context'.

You will notice that the filter pill turns grey. This is, in classic subtle Tableau style, your clue that the filter is 'in context.

Also worth noting is that context filters can be for single sheets, multiple sheets or all sheets. But it will be in or out of context for all sheets, you can't apply to many sheets and then switch in and out of context on different sheets.

Aggregation based filters (e.g. sum(sales)) cannot be added to context.

What does a Context Filter actually do?

In simple terms, putting a filter in context ensures that all other filters are dependent on that Context Filter. Tableau filters otherwise act independently and this is a useful feature, but may sometimes mean that filtering doesn't do what you might first expect it to do.