Sub topic 15
Charting a PivotTable with a PivotChart
A PivotChart is a chart that is tied to a PivotTable. It reads the same fields and values, so changing the PivotTable changes the chart, and filtering the chart filters the PivotTable. This chapter assumes you can already build a PivotTable with row, column and value fields, as covered in the earlier chapters.
How a PivotChart relates to its PivotTable
A PivotChart does not hold its own data. It displays whatever the PivotTable currently shows. Each area of the Fields pane maps to part of the chart:
| PivotTable area | Role in the chart |
|---|---|
| Rows | Categories on the horizontal axis (the axis field) |
| Columns | Separate series, shown in the legend |
| Values | The bar heights, line points or slice sizes |
| Filters | A report filter that limits which records are plotted |
Creating a PivotChart
Use the sample data from earlier chapters, with Region in Rows, Product in Columns and Sum of Sales in Values.
- Click any cell inside the PivotTable.
- On the PivotTable Analyze tab, choose PivotChart. You can also use Insert, then a chart type.
- Pick a chart type, such as Clustered Column, and select OK.
Excel places the chart on the sheet. Each region becomes a group of columns, and each product becomes a colored series within the group.
You can also create the chart first. Click a cell in the source range, choose Insert, then PivotChart. Excel creates a PivotTable and a PivotChart together.
Changing the chart through fields
Drag Product into Rows and Region into Columns. The chart swaps its axis and its series. This is the quickest way to decide which comparison you want to emphasise. Compare products within a region, or regions within a product.
The chart also shows field buttons, which are small drop-downs on the axis and legend. Use them to sort or filter without going back to the PivotTable. Slicers and timelines filter the chart as well. To hide the buttons, select the chart, then choose PivotChart Analyze, Field Buttons.
Choosing a chart type
Choose the type that fits the question:
- Column or bar charts compare categories.
- Line charts show change over time, for example Sales by month after grouping dates.
- Pie charts suit one series of parts of a whole, with few categories.
Common problems
- Formatting disappears after a refresh. In the chart's Format pane, make sure "Preserve cell formatting on update" is set in the PivotTable Options. For the chart itself, this is usually caused by changing the layout in a way that adds or removes series.
- The chart is stale. Refresh the PivotTable. The chart updates with it. See the refresh chapter for details.
- Deleting the PivotTable. The chart becomes a regular static chart with fixed values.
Exercise
You have a PivotChart showing Sales by Region, with Product in the legend. You want the chart to show one bar group per product, with regions in the legend. What do you change, and where?
Show answer
Swap the fields in the Fields pane: move Product to Rows and Region to Columns. The chart and the PivotTable update together because they share the same fields.
Exercise
Why might you filter a PivotChart before choosing a pie chart?
Show answer
A pie chart is hard to read with many slices. Filtering the PivotTable or chart to a few categories keeps the slices distinct and the chart readable.