Sub topic 8
Building a pie chart
This chapter assumes you can select a range, insert a chart from the Insert tab, and read the series and category terms from the earlier chapters. You will build a pie chart from a single series, add data labels, handle small slices, and recognize the cases where a pie is the wrong choice.
What a pie chart encodes
A pie chart shows how one total divides into parts. Each slice is one category. The angle and area of the slice show that category's share of the sum of all values.
A pie chart plots exactly one series. If you select two value columns, Excel draws a pie for the first column only and ignores the rest. This is the most common source of "missing data" in a pie.
The pie also assumes the values add up to a meaningful whole. Regional sales add up to total sales, so a pie fits. Average satisfaction scores for four products do not add up to anything, so a pie is misleading.
Prepare the data
Use the same layout as the column chart: one category column and one value column, with a header row.
Region Sales
North 120
South 95
East 140
West 80Pie charts need these conditions:
- All values are zero or positive. Excel cannot draw a negative slice. It plots the absolute value, so a negative number appears as a positive slice.
- The categories do not overlap. Do not mix a "Total" row with the regions it sums. Excel would treat the total as a slice, and the pie would show half its area as "Total".
- The number of categories is small. Aim for five or fewer.
Insert the pie
- Select the range, for example A1:B5, including the header row.
- Open the Insert tab.
- In the Charts group, choose Insert Pie or Doughnut Chart.
- Pick 2-D Pie.
Excel places the chart on the sheet. It uses the header in B1 as the default chart title and shows a legend with the four region names.
The total of the four values is 435. North is 120 of 435, which is about 27.6%. East is 140 of 435, about 32.2%. Excel calculates these percentages itself, so you never enter them.
Add data labels
The legend forces the reader to match colors to names. Labels placed on the slices remove that step.
- Select the chart.
- Choose the Chart Elements button (the plus sign beside the chart).
- Tick Data Labels.
- Open the arrow next to Data Labels and choose More Options.
- In the Format Data Labels pane, under Label Options, choose what to show.
| Label option | What it shows | Typical use |
|---|---|---|
| Category Name | The region name | Lets you delete the legend |
| Value | The raw number, such as 120 | When exact amounts matter |
| Percentage | The share of the total, such as 28% | The usual choice for a pie |
| Show Leader Lines | A line from a label to its slice | Labels placed outside the pie |
A good default is Category Name plus Percentage, with the legend removed. The reader then reads each slice directly.
Under Label Position you can choose Center, Inside End, Outside End, or Best Fit. Best Fit places labels inside when they fit and moves them outside when they do not.
Percentages are rounded to whole numbers unless you change the number format. In the Format Data Labels pane, open Number, choose Percentage, and set Decimal places to 1. Rounded percentages may add up to 99% or 101%. This is rounding, not an error.
Control the starting angle
Excel starts the first slice at 12 o'clock and moves clockwise in worksheet order. You can change this.
- Right-click a slice and choose Format Data Series.
- Under Series Options, set Angle of first slice.
Rotating the pie helps when two small slices land next to each other and their labels collide. Moving the first slice by 30 to 60 degrees often separates them.
Order the slices
Slices follow row order. A pie is easiest to read when slices run from largest to smallest, clockwise from the top. Sort the source data in descending order before charting.
Sorting the range changes the chart because the chart reads the cells. You do not need to rebuild it.
Region Sales
East 140
North 120
South 95
West 80Handle small slices
A slice under about 5% is hard to see and hard to label. You have three options.
- Combine small categories into one "Other" row in the source data.
- Switch to Pie of Pie or Bar of Pie, which pull the smallest slices into a second chart. Both are under Insert Pie or Doughnut Chart.
- Change to a bar chart, which handles many categories without crowding.
Combining categories needs care. Add the "Other" row by formula, such as =SUM(B6:B9). Then remove or hide the detail rows from the chart range so they are not counted twice.
Explode a slice
Explosion pulls a slice away from the center to draw attention to it.
- Click the pie once to select all slices.
- Click the target slice again to select only that slice.
- Drag it outward, or set Point Explosion in the Format Data Point pane.
Explode at most one slice. If every slice is pulled out, the emphasis is lost and the pie gets smaller to make room.
Avoid 3-D pies
Excel offers 3-D Pie. Perspective makes front slices look larger than back slices of the same value. Because the point of a pie is comparing angles and areas, this distortion defeats it. Use 2-D.
Doughnut charts
A doughnut chart is a pie with a hole. It is useful when you want to place a total in the center. It can also plot several series as concentric rings, but comparing arc lengths across rings is hard. For a single series, a pie and a doughnut carry the same information.
Build the same chart with VBA
The macro below uses the same range as the column chart example. Only the chart type changes, and it adds data labels.
Sub CreatePieChart()
Dim co As ChartObject
Set co = ActiveSheet.ChartObjects.Add(Left:=100, Top:=320, Width:=300, Height:=250)
With co.Chart
.SetSourceData Source:=ActiveSheet.Range("A1:B5")
.ChartType = xlPie
.HasTitle = True
.ChartTitle.Text = "Share of Sales by Region"
.ApplyDataLabels
End With
End SubApplyDataLabels uses the default label content. To show category names and percentages, set the properties on the series after that call:
Sub LabelPieWithPercentages()
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1)
.HasDataLabels = True
With .DataLabels
.ShowCategoryName = True
.ShowPercentage = True
.ShowValue = False
.NumberFormat = "0.0%"
End With
End With
ActiveSheet.ChartObjects(1).Chart.HasLegend = False
End SubRun CreatePieChart first. The second macro assumes the pie is the first chart object on the active sheet.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| Only one column appears | Pie charts plot one series | Select one value column, or use a different chart type |
| A "Total" slice takes half the pie | Total row included in the range | Exclude the total from the source range |
| Slices have numbers as names | The category column was read as a series | Use Select Data and set Horizontal (Category) Axis Labels |
| A slice is missing | The row is hidden or the value is blank | Unhide the row, or enable Show data in hidden rows and columns |
| Percentages total 101% | Label rounding | Add a decimal place or accept the rounding |
| Negative value shown as a slice | Excel plots the absolute value | Use a column chart for data with negatives |
When not to use a pie
Use another chart when any of these apply:
- You need to compare values precisely. People judge length better than angle, so a bar chart is easier.
- You have more than about six categories.
- The values do not sum to a whole.
- You want to show change over time. Use a line chart.
Exercise
A worksheet has the columns Product, Revenue, and Cost, with five products. A colleague selects all three columns and inserts a pie chart. The pie shows only revenue, and cost is missing. Explain why, and describe two ways to show each product's share of cost as well.
Show answer
A pie chart plots one series, so Excel draws the first value column (Revenue) and ignores Cost. To show cost shares, either build a second pie from Product and Cost (select those two columns, using Ctrl to select the non-adjacent range if needed), or use Select Data to change the series to Cost. If you need both measures side by side, a clustered bar or column chart is a better fit because it supports several series.
Exercise
You build a pie chart of six expense categories, and the two smallest slices (2% and 3%) overlap their labels. Name three changes that fix the problem.
Show answer
Any three of these: group the two small categories into an "Other" row using a SUM formula and exclude the detail rows; rotate the pie with Angle of first slice so the small slices are separated; switch to Pie of Pie or Bar of Pie; move the labels outside with leader lines; or switch to a bar chart.