Sub topic 14
Filtering interactively with slicers and timelines
This chapter assumes you can create a PivotTable, place fields in the Rows, Columns and Values areas, and use the Filters area. A slicer or timeline is a visual filter that sits on the worksheet. It does the same job as a field filter, but the current selection is always visible.
What slicers and timelines do
A slicer is a panel of buttons, one for each distinct value in a field. Clicking a button filters the PivotTable to that value. A timeline is a slicer for dates. It shows a scrollable bar of periods, and you select a range of months, quarters or years.
Both are linked to the PivotTable's cache. This is the stored copy of the source data that the PivotTable reads from. Because of this link, one slicer can control several PivotTables and PivotCharts built from the same source.
Adding a slicer
Use the sample data with Date, Region, Product, Units and Sales columns, and a PivotTable showing Region in Rows and Sum of Sales in Values.
- Click any cell inside the PivotTable.
- Open the PivotTable Analyze tab and choose Insert Slicer.
- Tick Region and Product, then choose OK.
- Click a button to filter. Hold Ctrl and click to select several buttons. Use the funnel icon with a red cross in the slicer's top-right corner to clear the filter.
Fields you filter with a slicer do not need to be in the PivotTable's layout. Product can be filtered even if it is not in Rows or Columns.
Adding a timeline
- Click a cell in the PivotTable.
- Choose Insert Timeline on the PivotTable Analyze tab.
- Tick Date and choose OK.
- Use the drop-down in the timeline's top-right corner to switch between Years, Quarters, Months and Days.
- Click a period, or drag across several periods, to filter.
A timeline needs a field that Excel recognises as real dates. If the dates were imported as text, the field does not appear in the list.
Connecting one slicer to several PivotTables
By default a slicer controls only the PivotTable it was created from. To link others, right-click the slicer, choose Report Connections, and tick each PivotTable it should control. The PivotTables must share the same cache. That is true when you copy a PivotTable, but not when you insert each one from the source separately.
Common errors
- The slicer does not filter another PivotTable. The two PivotTables use separate caches, or the connection was not ticked in Report Connections.
- Date is missing from the timeline list. The column contains text, not dates. Convert it, then refresh.
- A slicer shows old items. Deleted source values can linger. In the slicer's Slicer Settings, clear the option to show items deleted from the data source.
Exercise
You built two PivotTables by using Insert > PivotTable twice from the same range. A Region slicer on the first one does not appear in the Report Connections list for the second. What is the likely cause, and how would you avoid it?
Show answer
Each PivotTable created separately gets its own cache, so the slicer cannot connect to both. Create the second PivotTable by copying and pasting the first, or choose the first PivotTable's data when prompted, so both share one cache.