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

Note: If you are using Tableau 2020.2 or great i.e. have access to new Relationship Model, you will need to double-click on the originally pasted data source to open up before pasting in the Path Data.

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 like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy:

Also, do be sure to check out our various courses:

11 COMMENTS

  1. Hi Toan,
    Is there a way to tackle the overrun case over 100 via Gauges. Or in that case the most appropiate will be the bullet chart diagram?
    Thanks.

    • Hi Oscar, if you are exceeding 100 percent, I do think a bullet would be better. If you really want the gauge, you can always modify the data and calculations so that the total gauge is represents 200 percent, but this is not too extendable.

  2. Hi. In your tableau public dashboard you included the parameter LINE VALUE but not in your tutorial, then my dashboard does not work with this parameter..what should I do to make it works?

Leave a Reply

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