Sub topic 8
Pattern: switching between a chart and a table
This chapter assumes you can already use the Selection pane, create and update bookmarks, choose capture options, and assign a Bookmark action to a button. Here you combine those skills so one area of a page can show either a chart or a table of the same data.
Why use this pattern
A chart shows the shape of the data, and a table shows exact values. Putting both on the page costs space. With this pattern, the reader sees one at a time and switches with a button. The page stays uncluttered, and the reader still gets both views.
How it works
Both visuals sit in the same position. Each bookmark hides one visual and shows the other. A button applies the bookmark.
Build it
- Add a chart and a table that use the same fields, and give them the same size and position. Select both and use Format > Align to match them.
- Open View > Selection pane. Rename the visuals to "Sales chart" and "Sales table" so the bookmarks are easy to check.
- Hide the table by clicking its eye icon. Add a bookmark and name it "View - Chart".
- Show the table and hide the chart. Add a second bookmark and name it "View - Table".
- For both bookmarks, open the options menu. Turn off Data and leave Display on. Leave Current page on.
- Insert two buttons, for example "Chart" and "Table". For each one, set Action to Bookmark and pick the matching bookmark.
Turning off Data matters. If Data stays on, each bookmark stores the slicer and filter state from the moment you created it. Clicking a button would then undo whatever the reader had selected.
Show which view is active
A button can't know which bookmark was applied last. To mark the active view, build two copies of each button, one in an active style and one in a normal style. Each bookmark shows the active copy of its own button and the normal copy of the other. Stack the copies on top of each other and control them in the Selection pane. Then update both bookmarks so they include the new visibility settings.
Alternatively, use a single toggle button. Its bookmark action switches between the two views, and its label stays generic, for example "Switch view". This is simpler to build. It doesn't show which view is active.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Slicers reset when switching | Data is captured | Turn off Data in both bookmarks |
| Both visuals show | The bookmark was saved before one was hidden | Fix visibility in the Selection pane, then update the bookmark |
| Switching hides other visuals too | The bookmark has the wrong visibility state for other objects | Check every item in the Selection pane, then update |
| Button does nothing in Desktop | Ctrl+click is needed in Desktop | Hold Ctrl and click, or use Reading view |
Check your understanding
Exercise
A reader filters the report to one region with a slicer, then clicks your "Table" button, and the slicer goes back to "All". Which bookmark option is the most likely cause, and how do you fix it?
Show answer
Data is still turned on in the bookmark, so it restores the slicer state saved when the bookmark was created. Turn off Data in the bookmark options for both view bookmarks, then keep Display on so the visibility changes still apply.
Exercise
You added a new card to the page after creating both view bookmarks. Why might it behave unexpectedly when you click the buttons, and what should you do?
Show answer
The bookmarks were saved before the card existed, so they hold no visibility state for it. Set the card's visibility in the Selection pane for each view, then update both bookmarks.