Scenario
Let’s say we have two slicers:
- ShipCountry
- ShipCity
And we want to dynamically display the selected values from both slicers inside a text box or card.
Step 1: Set Up Your Visuals
Add two slicers to your report:
- One for ShipCountry
- One for ShipCity
Add a card and a text box that will display the selected values.
Step 2: Create the DAX Measure
Create a new measure in your model with the following code:
Multi-Slicer Selection =
VAR a = "Country: " & SELECTEDVALUE(Orders[ShipCountry], "All Country")
VAR b = "City: " & SELECTEDVALUE(Orders[ShipCity], "All City")
VAR c = UNICHAR(10) -- Adds a line break
RETURN
a & c & b
Explanation:
- SELECTEDVALUE returns the selected item, or the fallback value if multiple or none are selected.
- UNICHAR(10) adds a line break between country and city, so they appear on different lines.
- This measure can be placed inside both a card or text box.
Step 3: Add the Measure to a Text Box
Power BI now allows dynamic values in text boxes! Here’s how:
- Click on the Text box.
- In the floating formatting toolbar, click on the "fx" button next to the text area.
- Choose "Value" under the dynamic content options.
- Select your Multi-Slicer Selection measure from the dropdown.
- Click OK, and you're done!
You’ll now see the selected slicer values update dynamically based on user interaction.
Visual Output
If ShipCountry = Canada and ShipCity = Toronto, the output in the text box/card will be:
- Country: Canada
- City: Toronto
If no value is selected, it’ll show:
- Country: All Country
- City: All City
Final Notes
- This technique helps make reports more interactive and user-friendly.
- You can extend this approach to three or more slicers by adding more variables.
- Use it in tooltips or titles to reflect user selections dynamically!
Regards
Anmol Malviya
Sr. Data Analyst | Addend Analytics