Sub topic 7
Pattern: a show/hide filter panel
A show/hide filter panel lets users open a set of slicers on demand and close it again to give the charts more room. This chapter builds one from a group of visuals, two bookmarks, and two buttons.
Prerequisites
This chapter assumes you can do the following:
- Place visuals and slicers on a report page.
- Open the Selection pane and toggle a visual's visibility.
- Create a bookmark and set its Data, Display, and Current page options.
- Insert a button and assign it an action.
How the pattern works
A bookmark can store which visuals are visible. The pattern uses two bookmarks: one with the panel visible and one with it hidden. A button applies each bookmark. The user clicks "Filters" to open the panel and "Close" to hide it.
Build the panel
- Add the slicers you want, for example Category and Region. Add a rectangle shape behind them as the panel background.
- In the Selection pane, select the slicers and the rectangle, then group them (Ctrl+G). Rename the group
Filter Panel. - Add a button named
Open Filters(for example, the Filter icon from Insert > Buttons). Place it outside the panel. - Add a second button named
Close Filters(for example, the Back or Close icon) on top of the panel, near a corner.
Naming objects in the Selection pane matters here. Bookmarks refer to objects by position in the pane, and clear names make the later steps easier to check.
Create the two bookmarks
- Hide the
Filter Panelgroup with its eye icon. Also hideClose Filters, so it can't be clicked while the panel is closed. LeaveOpen Filtersvisible. - In the Bookmarks pane, choose Add and rename the bookmark
Panel hidden. - Show
Filter PanelandClose Filters, and hideOpen Filters. - Add another bookmark and rename it
Panel shown.
Now set the capture options on each bookmark. Select the bookmark's three-dot menu and clear the Data check box. Leave Display and Current page selected. With Data off, applying the bookmark changes only what is visible. It does not overwrite the slicer selections the user has made.
Assign the button actions
- Select
Open Filters. In the Format pane, open Action, turn it on, set Type to Bookmark, and choosePanel shown. - Select
Close Filters. Set Type to Bookmark and choosePanel hidden.
In Desktop, Ctrl+click a button to test it. Because the bookmarks' Display setting hides the other button, the open and close controls swap places.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Slicers reset when the panel closes | Data is still selected on the bookmark | Clear Data on both bookmarks, then update them |
| A new visual shows up in the wrong state | The bookmark's capture is set to Selected visuals, or the visual was added after the bookmark was created | Use All visuals, or update each bookmark after adding the visual |
| The panel opens but the Close button is missing | `Close Filters` was not made visible before the `Panel shown` bookmark was saved | Show it, then choose Update on the bookmark |
| Clicking the empty area behind a hidden panel does nothing | Expected behavior: hidden visuals don't receive clicks | None needed |
After you change visibility in the Selection pane, always choose Update on the matching bookmark. Bookmarks are snapshots, so later edits to the page are not saved to them.
Exercise
A user selects Category = Bikes in the filter panel, then clicks Close Filters. The report shows all categories again. Which bookmark setting is the most likely cause, and how do you fix it?
Show answer
The Data option is selected on the Panel hidden bookmark, so applying it restores the slicer state saved at creation. Clear Data on that bookmark (and on Panel shown), then choose Update on each.