Doughnut charts are not advisable in normal circumstances to be places on Tableau’s dashboard due to its confusion nature of showing the distribution of different measures in a dataset. However, when you have a single or at most two measures, one can apply doughnut charts for showing the distribution in terms of percentages.
The first part of this post is showing you how to do this without conditional coloring, while the second part shows you a slightly different approach to enable some conditional coloring in the doughnut.
For this article, we will be using this simple dataset which has three product names and the data of sales and their actual cost.
For calculating profit margin, we will be using this formula:
Usually while creating pie or doughnut charts, we will be using a category. But in this case, we don’t have one as far as this dataset is concerned. Therefore we need to create a second calculated field to fill in the rest of our doughnut chart
Creating a Doughnut Chart with No Color-Indicator
In the standard doughnut you drag your “Measure Values” into your Text Mark and your “Measure Names” into your Detail Mark. Now remove all measures except for our ProfitMargin and RestProfitMargin. It should look like this now:
Now please select your mark type to Pie
This selection of Pie will general a Pie Chart for you.
For generating a doughnut chart, add another measure into our row-section. You can either use “MIN(Number of Rows” or you can use a constant value of the dataset for applying the same effect. Just make sure both row measures have the same value.
As you can use, Tableau has made a multiple mark type visualization. For the second Mark remove the objects of the Color Marks, Angle Marks and Label Marks. Modify the Size Mark and make it slightly smaller. (You can set default color to white).
Finally, click on the second-row measure and click on the Dual Axis. It will generate a doughnut chart for you. Just clean up labels, hide headers and format your measures and you’re good to go.
Setting Up Conditional Coloring in a Single Measure Doughnut Chart
For generating conditional coloring, modify and use these calculated fields individually.
IF [ProfitMargin] >= 0 THEN [ProfitMargin] END
IF [ProfitMargin] >= 0 THEN 1-[ProfitMargin] END
IF [ProfitMargin] < 0 THEN [ProfitMargin] END
IF [ProfitMargin] < 0 THEN 1-[ProfitMargin]
These calculations will either return nothing or NULL if criteria is not matched.
Now do the same actions as a described in the first part using these 4 measures.
Now, edit the colors and choose the ones it seems the best combination for you
Adding up the ProductNames will generate this result:
Show the actual ProfitMargin in the inner circle of the doughnut chart and use the same conditional coloring. Simply add PositiveProfitMargin and NegativeProfitMargin to the Label Mark. Now edit the labels and add color to each of the labels.
The result will be: