Another Tableau Tutorial request. Here is a tutorial on creating Gauges in Tableau. In this tutorial, we are going to show the colour-coded percentage out of 100.

Note: This is an alternative type of data visualisation, and sometimes pushed for by clients. Please always look at best practices for data visualisations before deploying this into production.

Data

Load the following data into Tableau Desktop / Tableau Public.

Country,Value
United Kingdom,0.6
United States,0.8
Canada,0.25
France,0.5
Germany,1
Australia,0

Once your data is copied into Tableau, right-click on the data source and click on Edit Data Source… with the Data Source Editor open, paste the following:

Path,Position
1,1
101,1
1,1.5
101,1.5

You should get an error as there is no joining column, however, click on Add new join clause, go to Create Join Calculation, type 1 and click OK. Do this for the right-hand side as well. Ensure that you have Inner join selected and you should see the following:

Note: we need two records for each Country as we are going to be drawing lines and using densification to get more points on our canvas. For more information, check out our article on Data Densification.

Calculated Fields

With our data set loaded into Tableau, we are going to create the following Parameters, Calculated Fields, and Bins:

Line Value parameter

  • Set Name as Line Value.
  • Set Data type as Integer.
  • Set Allowable values as Range.
    • Set Minimum as 1.
    • Set Maximum as 10.
    • Set Current value as 1.

Large Every X parameter

  • Set Name as Large Every X.
  • Set Data type as Integer.
  • Set Allowable values as Range.
    • Set Minimum as 3.
    • Set Maximum as 10.
    • Set Current value as 5.

Path (bin)

  • Right-click on Path, go to Create and select Bins…
  • In the Edit Bins dialogue window:
    • Set New field name to Path (bin).
    • Set Size of bins to Line Value parameter.
    • Click Ok.

Index

(INDEX()-1)

TC_Position

WINDOW_MAX(MAX([Position]))

TC_Step Size

(WINDOW_MAX(MAX([Path]))-1)/WINDOW_MAX([Index])*1.8

Note: we are multiplying by 1.8 as our model goes to 100.

TC_Extend

IF [Index]%[Large Every X] = 0 AND [TC_Position] = 1.5 THEN
    1.2
ELSE
    1
END

TC_Color

IF [Index]/WINDOW_MAX([Index])<=WINDOW_MAX(MAX([Value])) THEN
    WINDOW_MAX(MAX([Country]))
ELSE
    "Grey"
END

X

COS(RADIANS([Index]*[TC_Step Size]))*[TC_Position]*[TC_Extend]

Y

SIN(RADIANS([Index]*[TC_Step Size]))*[TC_Position]*[TC_Extend]

Zero

0

With this done, let us start creating our data visualisation.

Worksheet

We will now build our first worksheet:

  • Change the Mark Type to Line.
  • Drag Country onto the Filter Shelf and choose United Kingdom.
  • Drag Country onto Rows.
  • Drag Path (bin) onto Rows.
    • Right-click on this object and ensure that Show Missing Values is selected.
    • Drag this object onto the Detail Mark.
  • Drag Position onto the Path Mark.
  • Drag X onto Columns.
    • Right-click on this object, go to Compute Using and select Path (bin).
  • Drag Y onto Rows.
    • Right-click on this object, go to Compute Using and select Path (bin).
  • Drag TC_Color onto the Color Mark.
    • Right-click on this object, go to Compute Using and select Path (bin).

If all goes well, you should now see the following:

We will now adjust the cosmetics:

  • Double click on the X-Axis and tick Reverse.
  • Hide the Y-Axis.
  • Hide the X-Axis.
  • Hide the Row Dividers.
  • Hide the Column Dividers.
  • Hide the Zero Line.

You should now see the following:

Now we will add our labels to the data visualisation:

  • Drag Zero onto Rows.
    • Right-click on this object and select Dual Axis.
    • Right-click on the Axis Header and select Synchronise Axis.
    • Hide the headers again.
  • In the Y Mark Panel, remove the Measure Names.
  • In the SUM(Zero) Marks Panel remove all the objects.
    • You should see a popup in the bottom right-hand corner with 1 null.
    • Click on this and select Show data at default position.
    • Change the Mark Type to Text.
    • Drag Country onto Text.
    • Drag Value onto Text, change the aggregation type to Max, and then format this as a Percentage. Adjust the text as you see fit.

With all that done, we should hopefully see the following:

and boom, we are done, do adjust the values of the Parameters, exploring the filter values, but most of all have fun, and you can find my data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/GaugeCharts/GaugeCharts

Summary

I hope you all enjoyed this article as much as I enjoyed writing it and as always do share the love. Do let me know if you experienced any issues recreating this Visualisation, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic. Do also remember to tag me in your work if you use this tutorial.

If you want to learn more about Creating Bespoke Data Visualisations in Tableau, do check out our course on Udemy at https://www.udemy.com/course/creating-bespoke-data-visualisations-in-tableau

7 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.