This post describes how to build a doughnut-chart with Tableau based on a calculated percentage (single measure). 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.
Now create your calculated field that looks like this:
Usually when creating pie-charts or doughnut-charts you would use a category field but in this case we can’t use that because we don’t have any categories for our data. Therefore we need to create a second calculated field to fill in the rest of our doughnut chart
Creating a doughnut chart with no specified 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 select the Mark Type Pie.
And now you have your Pie Chart:
For turning this into a doughnut chart we can easily add a measure into our row-section. I’m using the “MIN(Number of Records)” or you could you use a constant value for this. Just make sure both row measures have the same value.
As you can see, Tableau has made this into 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. (Maybe you can set default color to white)
How to setup conditional coloring in single measure doughnut chart.
To do so we need to create some (new/additional) calculated fields:
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]
The calculations will return nothing or NULL if criteria is not true.
Now do the same actions as a described in the first part using these 4 measures.
Because of the multiple measures we can now specify our color on the different measure. Edit colors of the [Measure Names]
If you add the ProductName on the columns you would get this result:
We can 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.