Tableau pie chart: full tutorial
The pie chart concept comes from old times. The pie distribution problem: how to divide a pie into X equal parts for X people. Nowadays people use pie charts to asses what components have the biggest share in some totality. In Tableau visualization, a pie chart is one of the most popular charts. For business applications, this chart is most appropriate to demonstrate profit by country, sales by client or expenditures by a company branch.
Creating a pie chart
To create a pie chart in Tableau, we need to have 1 and more dimensions and 1 or 2 measures. In this tutorial, I drag Sales to rows and Product Category to columns. However, a bar chart was created automatically at first. After that, we press Show Me and select pie charts. By doing so, we create a pie chart.
Other creation method
If we want to avoid creating a bar chart, we need to follow this instruction:
- Select Pie in the Marks field;
- Drag Sales (a measure that you want to asses) to Size and Angle buttons;
- Drag Product Category (a dimension by which you want to divide your measure) to Color button.
Formatting a Tableau pie chart
Changing a size for a Tableau pie chart is one of the most annoying tasks. We have to move our pointer to the right next to a pie chart. As our pointer changes it’s appearance to a two way arrow, we can press, hold and drag it to the right to widen chart size limiter. Also do the same with the bottom limiter to attain a bigger chart.
To display labels, drag Product Category dimension to a Label button. If you want your labels to be inside of a chart, you can click on those labels and drag to a center of an angle or wherever you want. To see what percentage of a whole share each category has, drag Sales to a label button. After that, select the SUM(Sales) label mark and add Quick table calculation – percent of total.
Tableau Donut chart
Donut chart is a variation of a Tableau pie chart. To create it, we need to:
- Drag Number of Record measure to rows column twice;
- Set measure to a minimum for both of those Number of Records marks that are in rows field;
- Then we select Dual-axis in the second Number of Records mark;
- In the marks field of MIN(Number of Records) 2, remove Product Category from colors;
- Then, press the labels button and mark out “Show mark labels” field;
- Select white color or whatever color that suits your Tableau worksheet;
- Press on Size button and shrink your additional pie chart that will serve as a donut hole;
- Select one of the axes and mark out a header.
Tableau Advanced: Gauge KPI chart
Business people love seeing Key Performance Indexes (KPI) expressed in Donut or Gauge charts. There are no pre-built Gauge chart in Tableau, so users are using their creativity to build it themselves. A Gauge chart in Tableau is usually just a half of the Donut Pie chart.
You can find a lot of tutorials over the internet of how to create Tableau KPI Gauge charts of different style:
Creation steps for Gauge chart
I am taking Gauge creation concept from Vizartpandey.com blogpost about creating semi donut chart, because it is as simple as possible.
First, we have to understand that default pie chart angle order can’t be used to represent a gauge chart. You can see why in this picture:
1. Creating supporting data and calculated fields
To change pie chart angle order so it would suit gauge chart, we need to create supporting data that will make new angles.
We add column ‘Number of Records’ and enter ‘1’ for every section row. Also, we do the same with whatever data for which we want to create gauge charts. You can do this addition in Excel easily. This will allow those rows cross-join, when doing FULL-OUTER join on ‘Number of Records’=’1’ in Tableau Data Source window. As a result, we will have 5 different sections for each row of our data-set.
We are going to create a gauge chart that will represent Free Throw percentage of NBA players. Lets use 2018-2019 season stats from https://www.basketball-reference.com.
Now we create calculated fields.
[Max %]– Free Throw Percentage Value based on each player
[Arc Angle] – Logical calculations needed to transform our percentage value so that it will be represented in upper half of a circle.
WHEN “Zero_To_Value” THEN IF ([Max %])<= 0.5 THEN ([Max %])/2 ELSE 0.25 END
WHEN “Value_To_50” THEN IF ([Max %])<= 0.5 THEN (0.5-[Max %])/2 ELSE 0 END
WHEN “After_50” THEN IF ([Max %])> 0.5 THEN (([Max %])-0.5)/2 ELSE 0 END
WHEN “Remainder” THEN IF ([Max %])<= 0.5 THEN 0.25 ELSE (1-([Max %]))/2 END
WHEN “Bottom Half” THEN 0.5
2. Build a Doughnut
To build a Doughnut chart that will be used to create a Gauge chart, we:
- Drag ‘Number of Records‘ to Rows field twice;
- Set the aggregation of it to minimum;
- Right-click on second pill of ‘MIN([Number of Records])’ and select Dual Axis.
- In the marks section, select first ‘MIN([Number of Records])’ mark and set the chart type to Pie. For the same mark, drag Sections to Color and Arc Angle to Angle.
- Then select second ‘MIN([Number of Records])’ and set the chart type to Circle. Add Max % to label of this circle and drag this label higher so it will be showing in the top part. Change circle color to white and reduce size of the circle. Now we see a doughnut.
3. Finish the Gauge chart
- Sort Sections manually in this manner (Also assign following colors):
Sections After_50 –Yellow Remainder –Grey Bottom Half –Any Color (Bottom will be hidden after we’ll fix the axis) Zero_To_Value –Yellow Value_To_50 –Yellow
- Drag Players to Filters card. Press Analysis –> Filters and add Players filter to the right panel. Change Players filter so it will be single value drop-down;
- Edit axis so it’s range will be fixed from 1 to 2;
- Remove axis headers so we will be left with a Gauge chart.
A lovely chart indeed
The pie chart is commonly used in Tableau and for a reason. It’s one of the best Tableau charts you can use. It presents data accurately, shows both proportions and values, and is very easy to interpret. Notably, the classical pie chart is easy to make. Additionally, there are more complicated variations of the Tableau pie chart like Donut chart, Gauge chart and Pie chart on Map. These charts can be used to represent data in BI visualization reports more clearly.