Sub topic 11
Layout, subtotals and number formatting
This chapter assumes you can already build a PivotTable with row, column and value fields, as covered in the earlier chapters. It shows how to change the report layout, control subtotals and grand totals, and format numbers so they survive a refresh.
Choosing a report layout
A PivotTable has three layouts. Pick one on the Design tab, under Report Layout.
| Layout | Row fields appear | Best for |
|---|---|---|
| Compact (default) | Stacked in one column, indented | Quick exploration |
| Outline | One column per field, subtotals above the items | Reading hierarchies |
| Tabular | One column per field, subtotals below the items | Copying values, using as a data table |
Compact layout puts several row fields in a single column, so you cannot give each field its own heading. If you plan to copy the results or reference them in formulas, use Tabular. Also choose Repeat All Item Labels on the same menu, so every row shows its labels.
Subtotals and grand totals
With two or more row fields, Excel adds a subtotal for each outer item. On the Design tab:
- Subtotals lets you show them at the top or bottom of each group, or turn them off.
- Grand Totals lets you turn totals on or off for rows, columns, or both.
- Blank Rows inserts an empty row after each item to make the report easier to scan.
To change the subtotal function for one field, right-click the field and open Field Settings. Choose Custom to show several subtotals at once, such as Sum and Average.
Formatting numbers the right way
Do not select cells and apply a format from the Home tab. When the layout changes, that formatting can be lost. Set the format on the value field instead:
- Click any cell in the value column.
- Right-click and choose Number Format, or open Value Field Settings and select Number Format.
- Pick a category such as Currency, and set the decimal places.
The format is stored with the field, so it stays after you refresh or rearrange.
Two further settings on the PivotTable Analyze tab, under Options, prevent surprises:
- Autofit column widths on update resizes columns on every refresh. Clear it if you set widths by hand.
- Preserve cell formatting on update keeps your fills and fonts after a refresh. Leave it on.
You can also type text in the For empty cells show box, for example 0 or a dash, to replace blank cells.
Exercise
You built a PivotTable with Region and Product as row fields. You want each region's name repeated on every row, with subtotals below each region. Which layout and extra setting should you choose?
Show answer
Choose Tabular as the report layout, then choose Repeat All Item Labels. In Tabular layout, subtotals appear at the bottom of each group by default.