Sub topic 2
Assigning Button Actions
Assume you can create Power BI visuals and slicers, use the Selection pane, and understand basic cross-filtering. This chapter uses bookmarks that you create in Power BI Desktop.
Assigning button actions
Select a button, open the Format pane, expand Button, and turn Action on. Choose an action type:
- Bookmark applies a saved report state.
- Page navigation moves to a selected report page.
- Back returns to the previous page.
- Apply all slicers applies pending slicer selections.
- Clear all slicers removes slicer selections.
For a bookmark or page navigation action, select the destination. Test the button in reading mode or by holding Ctrl while selecting it in Desktop.
A bookmark action changes only the state captured by that bookmark. It does not automatically change every visual or filter in the report.
Button states
Buttons can have different formatting for these states:
- Default: the normal appearance.
- On hover: the pointer is over the button.
- On press: the user is activating it.
- Disabled: the action is unavailable.
In the button's formatting options, select a state before changing its fill, text, outline, icon, or transparency. Use clear contrast and do not communicate state with color alone. A pressed or selected button should also have a visible label, icon, or outline.
Pattern: show or hide a filter panel
Create a panel by grouping the slicers and their labels. Use the Selection pane to show or hide that group. Add two bookmarks:
- Filters shown: the group is visible.
- Filters hidden: the group is hidden.
Set Display on for both bookmarks. Usually set Data off so opening or closing the panel does not reset slicer selections. Use Selected visuals when you want the bookmark to control only the panel and its related buttons.
Assign each bookmark to a button. Make the “Show filters” button visible when the panel is hidden, and make the “Hide filters” button visible when it is shown.
Pattern: switch between a chart and a table
Place the chart and table in the same position. Create two bookmarks:
- Chart view: show the chart and hide the table.
- Table view: show the table and hide the chart.
Turn Display on and Data off. Add buttons with bookmark actions. Use the button states to show which view is active. If the bookmarks unexpectedly change slicers, inspect their Data setting and recapture them.
Exercise
Why should a view-switching bookmark usually have Data turned off?
Show answer
Data off prevents the bookmark from restoring old filter and slicer selections while it changes only which visual is visible.