Sub topic 4
Adding and formatting buttons
This chapter assumes you can add visuals to a report page, open the Format pane, and use the Selection pane to rename and hide objects. Bookmarks and actions come in later chapters, so here you only place and style a button.
What a button is
A button is a report object that runs an action when a user clicks it. It can apply a bookmark, go to a page, go back, or clear slicers. A button has no data behind it. It is a shape with optional text and an optional icon, and you control its look in the Format pane.
Insert a button
- Open the report in Power BI Desktop and select the page.
- On the Insert tab, open Buttons in the Elements group.
- Pick a type, such as Left arrow, Right arrow, Reset, Back, Information, Help, Q&A, Bookmark, or Blank.
- Drag the button to the place you want and resize it by its handles.
Choose Blank when you want to style everything yourself. The other types are the same button with an icon and sometimes an action already set. You can change either afterward.
Format the button
Select the button and open the Format pane. The settings you use most are grouped as follows.
| Section | What it controls |
|---|---|
| Style: Text | Label text, font, size, color, alignment |
| Style: Icon | Built-in icon, its color and position |
| Style: Fill | Background color and transparency |
| Style: Border | Line color, width, and corner radius |
| Style: Shadow and Glow | Depth effects, best used lightly |
| Visual: Size and Position | Exact width, height, and placement |
| Visual: Padding | Space between the edge and the content |
| General: Alt text | Description that screen readers announce |
Each Style section has a state selector. Default is the look you see while editing. Hover, Pressed, and Disabled are separate looks, and the Button states chapter covers them. Format the default look first, then add the other states.
Position and size matter more than they seem. Set exact values for width and height so that a row of buttons lines up. Use Align and Distribute from the Format tab to space them evenly.
Use shapes as buttons
Shapes and images can also take an action. A rounded rectangle gives you the same result as a Blank button. A button is usually easier to maintain because it has built-in text, icon, and state formatting, while a shape needs a separate text box on top. Use a shape only when you need a form the button styles cannot make.
Name and arrange your buttons
New buttons get generic names such as "Button". In the Selection pane, rename each one to say what it does, for example "btn_ShowFilters". You will need these names when you build bookmarks, because bookmarks record which objects are visible.
Layer order matters too. An object higher in the Selection pane list sits in front. If a transparent shape covers a button, the click goes to the shape and the button seems broken.
Test it in Desktop
In Desktop, a click on a button only selects it. Hold Ctrl and click to run its action. Reading view and the Power BI service run the action with a plain click.
Common errors
- The button does nothing when clicked in Desktop. You forgot to hold Ctrl, or you have not set an action yet.
- The label is cut off. Increase the padding or the button width, or reduce the font size.
- A button is hard to click. Another object overlaps it, so move the button up in the Selection pane.
Exercise
You added a Blank button and clicked it in Power BI Desktop, but nothing happened, even though an action is set. What are two likely reasons?
Show answer
In Desktop you must hold Ctrl while clicking to run an action, so a plain click only selects the button. Another object, such as a transparent shape, may also sit in front of the button in the Selection pane and receive the click.