Sub topic 3
Slice by date and period
This chapter assumes you can build a pivot table, know that a header row names each column, and have used SUBTOTAL before. The sample data is the flat Data tab from earlier chapters, with Order Date in column B and Revenue in column F.
Slice by date and period
Add a slicer on the Order Date column. In the slicer panel, change the filter type from values to condition, then choose "Date is between" and set a start and end date. Only rows in that window stay visible. To compare two periods, add a second slicer to the same data range with a different window.
Add KPI cells that follow the slicers
Use SUBTOTAL instead of SUM. SUBTOTAL ignores rows hidden by a filter, so the totals change when a slicer changes.
Revenue (visible): =SUBTOTAL(109, Data!F2:F1000)
Orders (visible): =SUBTOTAL(103, Data!A2:A1000)
Average order: =IFERROR(SUBTOTAL(109, Data!F2:F1000) / SUBTOTAL(103, Data!A2:A1000), 0)Format the dashboard for readability
Place the KPI cells in one row at the top. Use a large, bold font and a currency format. Turn off gridlines for the dashboard tab through View, then Show. Align charts to the same column edges so the page reads top to bottom.
Share the dashboard with viewers
Click Share and add viewers with Viewer access. Then open the link in a private browser window to confirm the slicers work for a viewer. Hiding a tab does not restrict access, so keep sensitive raw data off the dashboard tab.
Troubleshoot slicers and know their limits
- A chart does not change: the chart's source range must match the slicer's data range.
- A KPI does not change: the formula probably uses SUM instead of SUBTOTAL, or its range differs from the slicer's range.
- Limits: a slicer filters only the data range it was built on, and it does not filter cells that use plain SUM.
Exercise
A slicer filters Order Date to January. Which formula gives the visible order count, and why not COUNTA?
Show answer
=SUBTOTAL(103, Data!A2:A1000). COUNTA counts every non-empty row, including rows the slicer hides, while SUBTOTAL with code 103 counts only visible rows.