Yes – it’s been a while since I blogged about anything; but figured now would be a good time to get back into the groove and release a long overdue post about how I created my ‘DESI – Digital Economy & Society Index’ dataviz which was recently voted as VOTD & VOTW on Tableau Public. Getting recognition for all the time and effort I put in over the last couple of months learning how to use Tableau and apply dataviz best practises was great, so this is my way of giving back.
Side note: if you want to read more about the design process, learn about some of my other fav tableau tips and tricks and what makes a great Liege waffle; make sure you check out my ‘Tableau Community Spotlight’ interview with Michael Sandberg.
Tutorial 1: Parameter ‘Filter’
Let’s start with something simple.
You know when you want to use your parameter as a filter but can’t change the formatting to blend in with the rest of your dashboard? This short tutorial will explain how I worked around that. And I invite you to use the sample workbook in case you want to follow along.
Step 1: create the country parameter
Right click on the ‘Country’ dimension > Create > Create Parameter (exclude the EU average)
Step 2: create the ‘Country Label’ worksheet
Start from a blank sheet, put the ‘Country’ dimension on Columns and Filters and drag the ‘Country Parameter’ you just created onto the sheet.
Next you’re going to add the parameter to the worksheet title via ‘Insert’.
Step 3: float the parameter and label worksheet onto your dashboard
And this is where the magic happens. By adjusting the W&H and formatting of the containers, you’re going to make them look as one.
For the ‘Country Parameter’, remove the parameter title & change the width of the container until only the drop-down arrow is visible.
Then float the label worksheet next to the parameter. On the worksheet change the Fit to ‘Entire View’ and adjust W&H of the container to show the country only; and have it line up right next to the dropdown arrow from the parameter.
Took me a while to figure out but it really is as simple as that.
Tutorial 2: Bar Chart with ‘Dynamic’ Colouring
Next you’re going to create the bar chart and use the ‘Country Parameter’ to highlight a specific country (in yellow) and at the same time show how that country ranked compared to the EU average (in blue).
Step 1: Create a simple bar chart
Put the ‘Country’ on Rows, ‘Weighted Score’ on Columns and ‘Year’ on filters (select 2018). Drag the ‘Country Parameter’ onto the worksheet.
Step 2: Create the calculation for the colouring of the bars/countries
Creating this calculation will:
- colour the country selected via the parameter colour 1 (yellow)
- colour the EU average in colour 2 (blue)
- and colour all the other bars in a different colour (grey)
Step 3: put ‘Country Colours’ on ‘Color’ in the marks card
Now that you’ve added ‘Country Colours’ to the sheet, try toggling the parameter to a different country and you’ll see the bar that’s coloured yellow shifts while the blue one (EU average) remains in the same position.
Step 4: adding the country ranking to the tooltip (first round)
And for some additional detail, you’re going to add the actual ranking number to the tooltips.
First try the the following table calculation.
If you now select Finland via the ‘Country Parameter’; the 3rd bar from the left will colour yellow but if you then validate the tooltip you’ll notice it will rank Finland as #1 which is not correct.
Next you could adjust the table calculation as shown below but that will only solve part of the problem. Finland will be ranked correctly as #3. However with the EU Average being one of the ‘Country’ values, it will be ranked as #15 and Slovenia as #16, while the EU should rank as 0 and Slovenia as #15.
Step 5: adding the country ranking to the tooltip (second round)
Let’s try something else. Why don’t you give the following calculation a try. What it’ll do is:
- for all the countries ‘before’ the EU Average (so where the total score is greater than the average) … they will be ranked using the calculation from Step 4
- the EU Average will be ranked as 0
- and all the countries after the EU average will receive an ‘adjusted’ ranking
Before testing, make sure you adjust the table calculation as shown below.
Pretty cool right?
Tutorial 3: Line Chart with ‘Dynamic’ Colouring & Sizing
The next chart you’ll create will display the scores over time for the different DESI dimensions (the’Indicator’ measure in the dataset).
Step 1: create the line chart
Put ‘Indicator’ and ‘Year’ on Columns, ‘Weighted Score’ on Rows and ‘Country’ on ‘Detail’ on the Marks card.
If you now drag ‘Country Colours’ (the calculation from earlier) to the Marks card and put it on Color, you’ll observe the following … a fine yellow & blue line on top of a bunch grey lines (each line representing a individual country).
Notice how the order of the lines is decided by the order in the colour legend: (1) being yellow on top of (2) being blue on top of (3) being grey and that’s what we want.
Now try changing the order by for example dragging the grey box (3) to the top. What would happen with the order of the coloured lines?
Answer: because the position of the colour in the legend dictates which colour will be on top when the marks overlap, the grey lines would be on top of the yellow and blue line which would make them almost invisible; and you want them to stand out. In fact you want the yellow and blue line to be a bit thicker so they are more visible.
Step 2: size the lines
Remember the calculation you created to colour the lines and bars?
If you drag ‘Country Colours’ onto ‘Size’ on the Marks card, this is what you’ll see.
How do you flip the result and have the yellow and blue line be thicker? You simply flip the calculation for ‘Country Colours’ by creating a second version as shown below. Notice the difference with the initial calculation?
All that’s left to do now is clean up the tooltips and you’re done. The ranking was already added to the dataset for you so there is no need to create calculations; but if you’re feeling adventurous, give it go and feel free to share the results with me or leave a note in the comments section at the end of the blog.
Tutorial 4: Creating the ‘Chart Header’ with the dimension definitions in the tooltip
And before we can wrap this up, there is one more thing left to do. You’re going to create the ‘Chart Header’ as shown in the image at the top of the page. Instead of showing the header of the ‘Indicator’ dimension (which is what you would normally do); you want to be able to hover over each indicator and show some additional information like the description/definition of each of the indicators (read DESI dimensions).
In order to do this you’ll have to connect the second sheet of the dataset to the workbook and pull in the definition information. For the purposes of this tutorial, I’ve already added it for you (see sample workbook).
Step 1: create the chart header
This is actually very simple.
Start a new worksheet and connect to the ‘DEFINITION DIMENSIONS’ datasource.
Put ‘Indicator’ on both Columns (uncheck ‘Show Header’) and Text on the Marks card and add ‘Definition’ to Tooltip. You’ll have to do some ‘clean-up’ but the end result should look something like the below.
Step 2: align the chart header with the line chart
All that’s left to do now is adding both sheets (the Chart Header & Line Chart) to the dashboard and do some re-arranging so that things line up nicely but I will leave that up to you, pretty sure you can manage 🙂
Thanks for reading and feel free to leave your feedback or questions in the comment section below.