How to Add Text to Button in Power BI
Power BI buttons are a fantastic way to make your reports interactive, but an icon or a colored shape doesn't always tell the full story. To guide your users and make navigation clear, you need to add descriptive text to your buttons. This guide will walk you through everything from the basic text label to creating dynamic, conditionally formatted text that responds to user selections.
Start with the Basics: Adding Static Text to a Button
The most common and straightforward way to add text is directly through the button's formatting options. This method is perfect for buttons with a fixed purpose, such as navigating to a specific page or applying a bookmark.
Let’s say you’ve inserted a blank button onto your report canvas (Insert > Buttons > Blank). A plain gray box will appear. Here’s how you bring it to life with text:
- Select the button you just added to your report canvas.
- With the button selected, look to the right for the Visualizations pane. Ensure you're on the “Format your visual” tab (the paintbrush icon).
- You'll see a list of formatting properties. Expand the Button section, and then find and expand the Text section within it.
- In the “Text” input field that appears, simply type what you want the button to say. For example, “View Sales Details.”
As soon as you type, the text will appear on your button. But we're not done yet. Under the text field, you have several options to style it:
- Font: Choose the font family, style (regular, bold, italic), and size.
- Color: Select a color that provides good contrast with your button's background color.
- Horizontal and Vertical Alignment: Center your text or align it to the left, right, top, or bottom. Typically, centered is the best choice.
- Padding: Adjust the space between your text and the edge of the button to prevent it from looking cramped.
Take a moment to adjust these settings until the button looks professional and is easy to read. A clear, well-formatted button makes a world of difference for user experience.
Level Up: Creating Dynamic Button Text with DAX
Static text is fine, but what if you want your button label to change based on what a user has selected in a slicer? This is where dynamic text using DAX (Data Analysis Expressions) becomes incredibly powerful. Imagine a button that updates from “View Overall Report” to “View 2023 Report” when a user selects the year 2023.
This provides direct feedback to the user, confirming their selection and clarifying what the button will do. Here's how to set it up.
1. Create a DAX Measure for the Button Text
First, we need to write a simple DAX measure that will generate our text string. This measure will check for a selected value in our slicer and insert it into the button's label.
Let's assume you have a 'Calendar' table with a 'Year' column that you're using in a slicer.
- Right-click on any table in your Data pane (on the far right) and select “New measure.”
- The formula bar will appear. Enter the following DAX formula:
Button Text = "View " & SELECTEDVALUE('Calendar'[Year], "Overall") & " Report"Let’s break down this formula:
"View "is the static text we want at the beginning. The space at the end is important!&is the ampersand, which is used to concatenate (join together) text strings in DAX.SELECTEDVALUE('Calendar'[Year], "Overall")is the key function at work. It checks if a single year is selected in the'Calendar'[Year]column. If it is, the function returns that year (e.g., "2023"). If no year is selected or multiple years are selected, it returns the alternate result, which we've set as "Overall."& " Report"is the static text that closes our label.
2. Apply the Measure to Your Button
Now that you have your measure, you need to tell the button to use it for its text value.
- Select your button on the report canvas.
- Go to the Format your visual pane again, and navigate to Button → Text.
- Instead of typing in the "Text" field, look for the small fx icon to the right of it. This stands for conditional formatting. Click it.
- A new window titled “Text - Text” will pop up. At the top, for Format style, select “Field value.”
- In the dropdown box below that says “What field should we base this on?,” find and select the measure you just created (“Button Text”).
- Click OK.
Your button will now display "View Overall Report." Go ahead and test it out! Click on a year in your slicer, and you'll see the button text instantly update to reflect your choice. This is a small detail that dramatically improves the interactivity and professionalism of your dashboard.
Enhance User Experience with Different Button States
Have you noticed that on most websites, a button changes its appearance when you hover your mouse over it or click on it? This visual feedback is crucial, it tells the user that the element is clickable and registers their interaction. You can - and should - replicate this behavior in Power BI.
Power BI buttons have several built-in states, and you can format the text (and other properties like fill color and border) for each one independently.
Select your button and navigate back to the format pane. At the top of the Button settings, you will see a dropdown menu labeled Apply settings to. By default, it’s set to “Default.” This dropdown is where you manage the states:
- Default: How the button looks when nothing is happening.
- On hover: How the button looks when the user's mouse cursor is over it.
- On press: How the button looks during the moment the user clicks it.
- Disabled: How the button looks when its action is not available.
How to Customize Text for Each State
- Start with your "Default" state text settings (color, size, etc.) already configured.
- Click the Apply settings to dropdown and select “On hover.”
- Now, navigate down to the Text section. The properties will look the same, but any changes you make here will only apply when a user hovers over the button.
- A great UX practice is to make a subtle change. For instance, if your default text color is dark gray, change the "On hover" text color to a brighter blue or make the font bold.
- Next, select On press from the dropdown. You might make the text color slightly darker here to mimic the effect of a physical button being pushed down.
Once you’ve configured the states, exit the formatting options and interact with your button on the canvas. You'll see the text style change smoothly as you hover and click, giving your report a much more dynamic feel.
Creative Workarounds: Using Other Visuals as Buttons
While the standard button visual is very capable, there might be times when you want more creative control. In these cases, you can turn a Text Box or a Shape into a functional button.
Using a Text Box
A simple text box can be an effective button, especially if you want more advanced text styling options not available in the button visual.
- On the ribbon, go to Insert > Text box.
- Type and format your text just as you would in any word processor. You have a lot of flexibility here with different fonts, colors, and sizes.
- Once your text looks right, select the text box. In the formatting pane, find the Action property and turn it on.
- Set the Type of action (e.g., Page navigation, Bookmark) and configure its destination.
The main drawback is that text boxes don’t have built-in "hover" or "press" states, so you lose that layer of interactivity.
Using a Shape
Shapes, like rounded rectangles, give you the best of both worlds: custom visuals and interactivity states (though for the shape's style, not the text's style directly).
- Go to Insert > Shapes and choose a rectangle or another shape.
- Select the shape and go to its formatting pane. Under the Shape section, you can customize the color, rounding, and border.
- Expand the Text section within the shape's formatting options and add your button text there. You can style the font, color, and size.
- Just like with a button, Shapes have the Apply settings to dropdown menu in their Style options. Instead of text styling, you can change the Fill Color or Border when a user hovers, giving a similar interactive effect.
- Finally, turn on the Action property for the shape to assign its function.
Final Thoughts
Adding clear, well-styled text to your Power BI buttons transforms them from simple shapes into intuitive navigational tools. You now know how to add static labels, create dynamic text that responds to slicers, enhance user experience with different visual states, and even use alternative visuals when you need more creative freedom.
Building high-quality reports involves mastering dozens of small details like this. While creating those pixel-perfect, interactive dashboards is ultimately very rewarding, it can be a time-consuming process. We built Graphed for those moments when you just need to get straight to the insights. By letting you use simple, natural language to connect your data sources and create real-time reports, we help you get answers in seconds, not hours, so you can spend less time configuring UI elements and more time acting on your data.
Related Articles
How to Enable Data Analysis in Excel
Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.