Our challenge for today is to help create a dynamic title in Power BI that changes based on filter selections.
Change report title text based on selection
Data Preparation
- Lauch Power BI Desktop
- Start by creating an EmployeeData table containing the following columns: EmployeeID (Integer), Name (Text), Department (Text), HireDate (Date) and Salary (Decimal).
Create dynamic measures
- Next, in the Modeling section, create individual measures for the different filter selections using the following DAX commands:
Selected Department =
IF(ISFILTERED(EmployeeData[Department]),
VALUES(EmployeeData[Department]),
"All Departments")
Selected Year =
IF(ISFILTERED(EmployeeData[HireDate]),
FORMAT(MAX(EmployeeData[HireDate]), "yyyy"),
"All Years")
Last, go ahead and combine measures into a dynamic title:
Dynamic Title =
"Employee Report: " & [Selected Department] & " - " & [Selected Year]
Explanations to comprehend the DAX code:
- The IF(ISFILTERED()) function checks if a filter is applied
- VALUES() returns the currently selected filter value
- Combining measures allows us to build a flexible title that is responsive to the user selection.
Add a card visual to your Power BI report
- Drag the [Dynamic Title] measure onto the canvas
- In the Visualizations pane, select the Card visual.
- Next, go ahead and format the card visual:
- In the Format pane, expand the Title section. Then set the Title text to “blank” (remove default title)
- Under Data label, increase the font size (e.g., 18 pt)
- Optionally, adjust colors and alignment as needed
Create slicers for dynamic title text selection
- Drag the Department and HireDate fields onto the canvas
- Highlight each of the fields in the canvas, and change their visual type to Slicer
Test the dynamic title by selecting different departments and years in the slicers
Common Issues when changing titles based on filters
- Title not updating: to fix this, ensure slicers are properly connected to the report page.
- Multiple values in title – Use CONCATENATEX() instead of VALUES() for multi-select scenarios.
- Blank title: Verify that measures are correctly referenced and calculated.