Gauge Chart in Tableau

Moving on to advanced Visualization I

Rohan Raj
7 min readMar 8, 2022

This blog is a part of the series on Advanced and Interactive Visualization,
which contains interactive and innovative ways to display data using advanced techniques in Tableau.

Where can we use this?

Oftentimes I come across requests from our clients to build necessary KPIs on the Dashboard, depicting the Sales-Profit-Revenue relationship across different products and customers, to see how they are performing as a business. But delivering a dashboard showing only KPI numbers can make it look a bit untidy and won’t attract their direct attention.

KPI Dashboard

How can we further make the Dashboard look attractive and make it depict the entire story that numbers can’t directly show you? For such scenarios, we can make use of Donut Indicators or Gauge charts. These are useful to monitor product performance against given parameters, compare Sales/Profit values against a certain threshold, etc.

Gauge Charts for KPIs

Dataset and Prerequisites:

The data used for this project can be accessed from here. The dataset contains the Retail data of a global superstore for 4 years.

This requires an understanding of some Tableau concepts like Calculated Fields, LODs, Donut Chart.

Where to Begin?

We are going to create a Gauge Chart to indicate the percent Sales for each year and a combination of years given the total sales for all 4 years.

First, we will create a calculated field - “SalesPercent”, using Fixed LOD to depict percent Sales for each year against total Sales. This value will be used later in our chart to act as an indicator for Year sales.

Create another Calculated Field “Value” which will store this percent value and will be used to create necessary indicators for our Gauge chart.

The idea is to color the donut slices according to the value of the %.

If the value is less than 33%, it will be red.

If the value is between 33% and 66%, it will be yellow.

If the value is more than 66%, it will be green.

Start creating the chart

  1. Create a Donut chart
Donut Chart

2. Next, we will create Calculated Fields to get angles and colors for all the slices.

NPS-1 Red (Color 1st Half of Gauge)

IF [VALUE]<=.33 THEN [VALUE] ELSE 0 END

Mark the slice Red if VALUE is less than 0.33 or 33%.

NPS-2 Yellow (Color 1st Half of Gauge)

IF [VALUE]>.33 AND [VALUE]<=.5 THEN [VALUE]

ELSEIF [VALUE]>.5 AND [VALUE]<.=66 THEN .5

ELSE 0 END

Mark the slice Yellow if VALUE b/w 0.33 and 0.5, else if VALUE b/w 0.5 and 0.66, then mark only slice till 0.5(or 50% of Gauge) as yellow. Rest, we’ll create another cal field to mark part b/w 0.5 and 0.66 as yellow.

NPS-3 Green (Color 1st Half of Gauge)

IF [VALUE]>.66 THEN 0.5 END

Mark the 1st half slice as complete Green if VALUE is greater than 0.66 or 66%. The part in the 2nd half also shows Green in the above picture because of another calculated field created later to color the 2nd half.

NPS-4 Grey (Color 1st Half of Gauge)

Marking encircled part as grey in this calculated field

IF [VALUE]<=.5 THEN .5-[VALUE]

ELSEIF [VALUE]>.5 AND [VALUE]<.66 THEN 0

ELSE 0 END

Mark the remaining slice after VALUE as Grey, and if VALUE is greater than 0.5, then don’t mark any part as grey for now.

NPS-5 Yellow (Color 2nd Half of Gauge)

Marking encircled part as Yellow

IF [VALUE]>.5 AND [VALUE]<=.66 THEN [VALUE]-.5 END

Mark the remaining part b/w VALUE and 0.5 as Yellow. (Whole 1st half slice till 0.5 was already colored Yellow in the NPS-2 cal field for VALUE>0.5 condition)

NPS-6 Green (Color 2nd Half of Gauge)

Marking encircled part as Green

IF [VALUE]>.66 THEN [VALUE]-.5 END

If VALUE greater than 0.66, Mark the remaining part b/w VALUE and 0.5 as Green (Again, whole 1st Half was already Green from NPS-3 cal field logic)

NPS-7 Grey (Color 2nd Half of Gauge)

Marking encircled part as Grey

IF [VALUE]<=.5 THEN .5

ELSEIF [VALUE]>.5 THEN 1-[VALUE] END

Mark the remaining part in 2nd part of the slice as Grey.

NPS-8 White (Color 3rd Half of Gauge)

MIN(.70)

This decides the width of the 3rd part of the Gauge chart. If we kept the value as .50, the shape would have been an entire semi-circle.

Needle1

IF [VALUE]>=.5 THEN .01 END

Needle2

IF [VALUE]<.5 THEN .01 END

Above 2 will act as respective Needles for the 1st and 2nd Half of our Gauge Chart.

All Calculated Fields after above creation

3. Drag Measure Names to “Color” and Measure Values to “Angle” to get the respective angles acc to the logic used in cal fields. Edit Filter for Measure Names and select only the 10 Cal Fields that we created above.
Also, you can change the colors of slices accordingly.

Our Gauge Chart will now start taking shape. But, if you notice, it is tilted to the right side. This happens because, in Tableau, pie charts usually start from 90deg (vertical top) and move clockwise. So 1st Half of the Gauge starts from the vertical top instead of the left side from where we want. So, all slices have to be arranged in a similar manner, like below.

Rearrangement of Measure Values

4. We need the 2nd smaller pie chart of our Donut to vanish, to get the correct shape of our Gauge Chart.

This part needs to vanish

For this, we’ll create a dummy Cal Field, with value as “dummy”, put it on the 2nd pie chart, and make it similar to the background color, white in our case.

Open the Color section for 2nd Pie of the Donut, and change the color of all fields to White and just the color of both Needles to Black.

This will give us the final version of our Gauge Chart.

Gauge Indicator

If we use this Gauge Chart in a Dashboard, along with the “SalesPercent” field created earlier (keeping it below the Gauge Indicator), and use them combined with the Year filter, we can get a view something like below:

Gauge Indicators for Yearly Sales

Such levels of indicators can better inform the management about the Sales performance or what portion of the decided threshold is yet to complete.

Gauges can be good when they are used to display a standalone KPI, as they are easy to understand. But they are pretty bad in situations where you’re comparing multiple values. I share this technique not because it’s the way you should do it, but because there could be a time when it makes sense, for whatever reason. But you should avoid using a chart like this simply because it looks cool. While visual appeal is often important, you can still create visualizations with both visual appeal and strong analytical precision at the same time.

One can view other such viz from the Tableau link.

The part II of this series of Advanced Visualization is on Calendar Reports.

--

--

Rohan Raj

Analytics Enthusiast, Data Fanatic, Solving problems with Data