Toan Hoang

Dual-Metric Doughnut Chart Tutorial

I created this data visualisation in Tableau when I was exploring Sunburst charts, and drawing polygons, but never did release an article on it. But given I just finished my article series on creating Tableau Extensions, I thought it would be a good time to give this a try.

Disclaimer: This tutorial goes through several techniques which will hopefully help you in your journey. However, and as always, try to find the most appropriate visualisation for specific data visualisation and dashboard requirements.

Data

We will start by loading the following data into Tableau.

SegmentPathProfitQuantity
A1800200
A202800200
B110001000
B20210001000
C1600500
C202600500
D12000400
D2022000400
E1800800
E202800800
F1100800
F202100800
G150100
G20250100
H1200200
H202200200
I1800800
I202800800

Note: We have two records per segment as we are going to use data densification to give us additional points for drawing.

Calculated Fields

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

Path (bin)

Index

INDEX()-1

TC_Profit

WINDOW_MAX(MAX([Profit]))

TC_Total Profit

WINDOW_SUM(SUM([Profit]))/2

TC_Total Profit (Previous)

(RUNNING_SUM([TC_Percentage of Total Profit])-[TC_Percentage of Total Profit])*360

TC_Percentage of Total Profit

WINDOW_SUM(SUM([Profit]))/[TC_Total Profit]/2

TC_Total Quantity

WINDOW_MAX(MAX([Quantity]))

TC_Percentage of Total Quantity

WINDOW_SUM(SUM([Quantity]))/[TC_Total Quantity]/2

X

IF [Index]<101 THEN
SIN((([Index]*[TC_Percentage of Total Profit]*3.6)+[TC_Total Profit Previous])*PI()/180)
ELSE
SIN((((201-[Index])*[TC_Percentage of Total Profit]*3.6)+[TC_Total Profit Previous])*PI()/180)*(1+[TC_Percentage of Total Quantity])
END

Let us spend a little time here explaining how we are using our other Calculated Fields:

Y

IF [Index]<101 THEN
COS((([Index]*[TC_Percentage of Total Profit]*3.6)+[TC_Total Profit Previous])*PI()/180)
ELSE
COS((((201-[Index])*[TC_Percentage of Total Profit]*3.6)+[TC_Total Profit Previous])*PI()/180)*(1+[TC_Percentage of Total Quantity])
END

So now that we have created a lot of Calculated fields, we will now put this together into a Worksheet.

Worksheet

We will now build our worksheet:

You should see something like the following:

You can see that we have drawn a full 100% doughnut per Segment, need not worry, we will adjust the Table Calculation to get the visualisation we require:

If you have done this correctly you should now see the following:

and boom, you have now built a worksheet that shows a doughnut with two metrics. the distance around the Circle represents the percentage of Profit, the Distance from the centre represents the percentage of Total Quantity.

Adjusting the Visual

We will now do the following to get the look that we require:

You should have something like the following (I filtered some some segments):

and that’s a wrap… and here is the Tableau Public link: https://public.tableau.com/profile/toan.hoang#!/vizhome/Dual-MetricDoughnut/Dual-MetricDoughnut

Summary

I hope you all enjoyed this article as much as I enjoyed writing it. 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.

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