Sub topic 3
Switching Time Levels and Selecting Date Ranges
Assume you can create a PivotTable, insert a timeline, and distinguish true Excel dates from text. This chapter connects timeline controls to reports and helps you choose the right filter.
Switch time levels
A timeline filters a date field continuously. Use its drop-down to switch between Years, Quarters, Months, and Days. The visible scale changes, but the selected period remains a date range.
Drag across the timeline to select a range. Drag the handles to adjust its start or end. Click a single period for one year, quarter, month, or day. Use the Clear Filter button on the timeline to show all dates again.
Connect one control to several PivotTables
Select the slicer or timeline, then choose Slicer > Report Connections or Timeline > Report Connections. Select each PivotTable that should respond.
The PivotTables usually must use the same PivotTable cache, which is the shared internal data source. A PivotTable based on a different cache may not appear in the list.
Choose the right filter
| Filter | Best use |
|---|---|
| Report filter | Compact filtering with limited screen space |
| Slicer | Visible selection of text or category values |
| Timeline | Selecting ranges from a true date field |
Use a slicer for Region or Product. Use a timeline for Order Date. Use a report filter when the control should remain compact.
Arrange an interactive report
Place slicers and timelines together above the PivotTables. Resize them so important items are visible. Use multiple columns for long category lists. Apply a consistent style, but keep selected and unselected items easy to distinguish.
Troubleshoot common problems
- A disabled timeline usually means the field contains text, blanks, invalid dates, or no usable date field.
- A missing PivotTable in Report Connections often means it uses a different PivotTable cache.
- A slicer with unexpected items may need Slicer Settings > Hide items with no data.
- If results look stale, right-click the PivotTable and choose Refresh.
Automate connections with VBA
This macro creates a Region slicer for the first PivotTable and connects the second PivotTable to the same cache.
Sub AddAndConnectRegionSlicer()
Dim pt1 As PivotTable
Dim pt2 As PivotTable
Dim sc As SlicerCache
Set pt1 = ActiveSheet.PivotTables(1)
Set pt2 = ActiveSheet.PivotTables(2)
Set sc = ActiveWorkbook.SlicerCaches.Add2(pt1, "Region")
sc.Slicers.Add ActiveSheet, , "RegionSlicer", _
"Region", 10, 400, 140, 150
sc.PivotTables.AddPivotTable pt2
End SubThe field name and PivotTable cache must match your workbook.
Exercise
A timeline filters one PivotTable but not another. What should you check first?
Show answer
Open Report Connections and select the second PivotTable. If it is absent, verify that both PivotTables use the same PivotTable cache.