Toan Hoang

Creating Gauges in Tableau

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

Large Every X parameter

Path (bin)

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:

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

We will now adjust the cosmetics:

You should now see the following:

Now we will add our labels to the data visualisation:

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:

Exit mobile version