Sub topic 14
Charting a pivot table
This chapter assumes you can build a basic pivot table with rows, columns, and values, and that you can insert a chart and use the chart editor. A pivot table summarises raw data, and a chart drawn from it shows the summary instead of every record. The chart is linked to the pivot table, so it changes when the pivot table changes.
Why chart a pivot table instead of the raw data
Raw data often has one row per transaction. Charting thousands of rows gives you a crowded chart, or one that Sheets cannot group the way you want. A pivot table does the grouping first: it adds up sales by region, counts orders by month, or averages scores by class. The chart then draws a handful of totals.
A pivot-based chart also stays current. When you add rows to the source data, the pivot table recalculates, and the chart redraws from the new result. You do not need to adjust a data range by hand.
A worked example
Suppose the sheet Sales holds these columns, with one row per sale:
Date Region Product Sales
2026-01-05 North Widget 120
2026-01-09 South Gadget 80
2026-02-11 North Gadget 150
2026-02-14 East Widget 95Build the pivot table like this:
- Select the data, including the header row, then choose Insert > Pivot table. Place it on a new sheet.
- In the pivot table editor, add
Regionunder Rows. - Add
Productunder Columns. - Add
Salesunder Values and set Summarize by to SUM.
You now have a grid with regions down the side and products across the top. Each cell holds the total sales for that pair.
Inserting the chart
- Click any cell inside the pivot table.
- Choose Insert > Chart.
- Sheets suggests a chart type. For a grid like this it usually picks a column chart. Change it in the Setup tab of the chart editor if you want something else.
In the Setup tab, the data range refers to the pivot table. The Rows and Columns choices you made in the pivot editor decide the chart's layout. Row labels become the categories on the horizontal axis, and each Columns item becomes a series, which is one coloured set of bars.
How pivot fields map to the chart
| Pivot table editor | What it becomes in the chart |
|---|---|
| Rows field | Categories along the axis (the x-axis in a column chart) |
| Columns field | One series per item, shown in the legend |
| Values field | The bar heights or line positions |
| Filters | Records left out before the chart is drawn |
If you have no Columns field, the chart has a single series. If you add a second Values field, such as SUM of Sales and COUNT of Sales, each one becomes its own series. Those two measures use very different scales, so you may need a combo chart with a secondary axis.
Choosing a chart type for pivot output
The shape of the pivot table narrows your choices:
- Rows are categories, Columns has a few items: use a clustered column chart to compare items within each category, or a stacked column chart to show how the parts add up to a total.
- Rows are dates: use a line chart. Group the dates in the pivot table first, for example by Year-Month, using the right-click option Create pivot date group. Otherwise you get one point per day.
- One Values field and no Columns field, with few rows: a pie or bar chart works. Avoid pie charts when there are more than five or six slices.
- Many categories with long names: use a bar chart, which puts the labels on the vertical axis where they have room.
Controlling what the chart shows
You control a pivot chart in two places, and it helps to know which one to use.
Change the pivot table editor when you want to change what is measured or grouped:
- Add or remove fields in Rows or Columns.
- Apply a filter, such as showing only 2026 or only two regions.
- Change the summary function from SUM to AVERAGE or COUNT.
- Use Show as to display values as a percentage of the row, column, or grand total.
- Sort by a value, for example Region sorted by SUM of Sales descending, so the chart shows a ranked list.
Change the chart editor when you want to change how the result looks: chart type, titles, colours, axes, gridlines, and legend.
Sorting in the pivot table is the simplest way to order the categories on the chart. The chart follows the order of the pivot table rows.
Grand totals
Pivot tables can add a Grand total row and column. If the totals appear in your chart as an extra bar or a huge extra series, they swamp the real categories. Turn them off in the pivot table editor by clearing the Show totals option for Rows and Columns. Then check the chart again.
When the pivot table changes size
A pivot table grows and shrinks as the data changes. A new region adds a row, and the chart gains a category. Two things can go wrong:
- Overwritten data. If you put other data directly below or beside a pivot table, a growing pivot table cannot expand. Sheets shows an error saying the result would overwrite data. Keep the pivot table on its own sheet, or leave empty space around it.
- Colour drift. When a new item appears in Columns, it becomes a new series with a default colour. Colours you set by hand for existing series normally stay. A new series may not match your palette, so check the chart after the data changes.
You cannot type over cells inside a pivot table, because the pivot table owns them. Fix problems in the source data or in the editor settings.
A formula alternative
A pivot table is not the only way to feed a chart a summary. A QUERY formula can produce a similar summary table in ordinary cells:
=QUERY(A1:C100, "select A, sum(C) where B = 'North' group by A label sum(C) 'Sales'", 1)This formula builds a small table of total sales per value in column A for the North region. You chart that output as you would any range. The formula gives you more control over filtering and labels, and it updates when the source rows change. The pivot table is faster to set up with point-and-click and offers features like date grouping and Show as. Choose the pivot table for exploration and the formula when you need an exact, repeatable layout.
Common problems
- The chart shows a "Grand Total" category. Turn off Show totals in the pivot table editor.
- The series and categories are the wrong way round. Swap the Rows and Columns fields in the pivot table editor. You can also use Switch rows / columns in the Setup tab, if it is offered for your chart.
- The chart has one point per day. Group the date field in the pivot table, by month or year.
- Blank or "(blank)" categories appear. The source data has empty cells in a field you used in Rows or Columns. Fill them in, or add a filter that hides the blank value.
- The chart does not change after you edit the source data. Check that the pivot table's source range covers the new rows. If you added rows outside the range, edit the source range in the pivot table editor.
- Values are counted instead of summed. Numbers stored as text make the pivot table default to COUNT. Convert them to numbers in the source data and set Summarize by to SUM.
Summary of the workflow
- Prepare source data with a single header row and consistent values.
- Build the pivot table, choosing Rows, Columns, Values, and filters.
- Turn off totals you do not want charted, and sort the categories.
- Click inside the pivot table and choose Insert > Chart.
- Pick a chart type that fits the pivot table's shape.
- Format titles, colours, and the legend in the chart editor.
Exercise
A pivot table has Month in Rows, Region in Columns, and SUM of Sales in Values. The chart has a very tall extra bar at the end of the horizontal axis labelled "Grand Total", and the other bars are tiny. What should you change, and where?
Show answer
Turn off the totals in the pivot table editor by clearing Show totals for Rows, and for Columns if a total series also appears. The chart follows the pivot table, so removing the Grand total row removes the oversized bar. Changing the chart editor settings would not fix it, because the totals come from the pivot table.
Exercise
You want a chart of average order value by product category, ranked from highest to lowest. Which fields and settings do you use in the pivot table editor, and how do you get the ranking onto the chart?
Show answer
Put the category field in Rows and the order value field in Values with Summarize by set to AVERAGE. Sort the Rows field by the AVERAGE value, descending. Then insert a chart from the pivot table, such as a bar chart. The chart keeps the pivot table's row order, so it shows the highest average first.