9 Replies Latest reply on Jun 10, 2019 12:52 AM by Setiadi Darmawan

# Gauge Chart In Tableau

I had been getting this frequent requirement of creating a Gauge Chart and I like always thought that it is not possible to create one in Tableau, until I came across Adam McCann’s post where he actually explained how to create a Gauge chart in Tableau. He presented with Chris DeMartini at the Tableau Conference in Austin on how to create custom chart types in Tableau and this was one of them. Ever since this has been one visualization which I am fond of .

Let us execute these steps to create a Gauge Chart in Tableau by using Sample Superstore dataset. We will be showing the Sales of various Sub Categories through Gauge Chart.

Step-1:

Show the Sub Category Sales.

Step-2:

We will create a Calculated Field that will normalize the Sales and change the Sales to percentage. The formula will be:

Sales% = SUM([Sales]) / WINDOW_MAX(SUM([Sales]))

Go to the Data pane and right click the field Sales%. Go to Default Properties → Number Format → Percentage. Now this will show the Sales % value in % like below image:

Step-3:

Now, we have to create the Gauge Arch. Since we will create a semi-circle Gauge we will create an Angle field as semi- circle and plot X and Y points.

Create a Calculated field Angle with the following formula:

Angle = Sales% * 180

This will give us the plotting in semi- circle manner and we will use this field for some more calculations. Also, make this as Number Whole from the data pane→ Change Data Type option. When we bring this field to the viz, because it’s a table calculation Compute Using Sub Category.

Create a Calculated field X with the following formula:

X = 1 + SQRT(2) * COS((1-[Sales%])*180 * PI() / 180)

Create another Calculated field Y with the following formula:

Y = 1 + SQRT(2) * SIN([Angle] * PI() / 180)

The  X and Y calculated field created here will be a table calculation; so when we bring it to the sheet we will check Compute Using- Sub Category.

Now, let’s plot X & Y on the sheet with Sub Categories in Detail shelf. Check X & Y field to make it Compute Using→ Sub Category. The viz will look like below:

Step-4:

Create a parameter that will help you choose a Sub Category and plot another Sub Category as origin.

Now add this parameter in previously created X and Y field. For better understanding I have created altogether a new X with parameter and Y with parameter calculated field again.

X with parameter = IIF(ATTR([Sub-Category])=[Parameters].[Sub-Category],

1 + SQRT(2) * COS((1-[Sales%])*180 * PI() / 180),1)

Y with parameter = IIF(ATTR([Sub-Category])=[Parameters].[Sub-Category],

1 + SQRT(2) * SIN([Angle] * PI() / 180),1)

Step-5:

Add X with parameter & Y with parameter in the viz and choose Compute Using -- Sub Category for both the fields.

Drop Sub Category in Detail shelf. The viz will look like below after editing the X axis:

Because we want to show the Sub Categories as a pointer in the gauge; we will change the circles to a line for better formatting, like below:

Step-6:

Add a Background Image in the workbook:

When you click on the data set Name- Orders(Sample- Superstore) in this case, you will get the below dialogue box:

Click on Add Image and then browse for the gauge image.

So, after adding the Background Image the dialogue box looked like below:

Pay extra attention to the highlighted area as those are the changes that you have to make after browsing for the Image in Tableau.

Once done, you will have to Edit X Aix by fixing the Range from -0.5 to 2.5 like below:

Now, the vix looked like below:

Step-7:

Finally, we will do some beutification to finish up the viz. Duplicate thr field Y with parameter that is in Row shelf by dragging another one from the data pane to the row shelf.Once done, you will notice that you have 3 Marks card now. Go to one of the Marks Card for Y with parameter and bring out the Shapes. Choose the shape you want- I choose a Diamond. Then Synchronize your dual axis and hide the Axis that appears on the right side. Put the Parameter, Sales and Sales% field in the Marks Card that shows Shapes.Bring the parameter to sheet by selecting Show Parameter Control. Your Gauge Chart is ready and looks like below:

• ###### 1. Re: Gauge Chart In Tableau

Thanks for sharing Akriti!

Cheers,

Byrne, Patrick

• ###### 2. Re: Gauge Chart In Tableau

Thanks Akriti for sharing this...

1 of 1 people found this helpful
• ###### 3. Re: Gauge Chart In Tableau

Hi Akriti,

I am trying to create this on Tableau 2018 2.2 and not able to plot x and y properly and also my line is not coming vertically.

Regards.

• ###### 4. Re: Gauge Chart In Tableau

WOW, that's awesome, thanks Akriti

• ###### 5. Re: Gauge Chart In Tableau

Hello Akriti,

Your Gauge creation in Tableau is remarkable.
However, my gauge requirement is little different from yours and it would be great if you could help me with it.

Please check the dummy data below, since I cannot share the sensitive data. (the gauge only represents the requirement and is not calculated based on the data below)

My requirement is that instead of choosing parameter to select the sub category, I would like to display the single calculated field in the gauge.
In this case "Calculated Target percent". I would also like to display "Calculated Control percent" in the view.

so, for a gauge starting form 0% and ending at 100% I would like to display only the calculated fields (66.20% and 68.04%)

Do you have any idea how to create such a view?

If more information is required to understand better, I am happy to explain more in detail.
Thank you.

Kind regards,
Gayatri

• ###### 6. Re: Gauge Chart In Tableau

Hi, I do have similar requirement to show two lines, planned and actual, can you please let me know if you have solution

• ###### 7. Re: Gauge Chart In Tableau

Hello Bhimeswara,

The way it worked for me was that I used the same method as described above but with small modifications.

The calculations I wanted, I performed them before connecting it to Tableau (I did not calculate in Tableau,I used SQL for it then connected the data to Tableau).

Then I followed the steps as above but by creating two different parameters (in your case actual and planned).

I kept both the parameters' selections constant (in your case one parameter to be selected as planned and the other as actual).

Then I put it up together in the dashboard and ta da

If you need more details, possible share your workbook if possible.

good luck!!

• ###### 8. Re: Gauge Chart In Tableau

Hi Akriti

I appreciate you posting a solution to the multi-year request from Tableau users for a gauge chart.  What you have here is quite complex.  Is it possible to post a copy of the workbook so I can recreate this on my own.

Thanks

Allison

• ###### 9. Re: Gauge Chart In Tableau

Hi..

how about create a gauge starting form 0% and ending at 120%?

in my opinion only change the angle, but all X param and Y param length become not correct.

Which formula I should change?

Thanks