Concept Breakdown
The SELECTEDVALUE function returns the value when there's only one distinct value in the specified column, otherwise it returns an alternate result (or BLANK). This is ideal for dynamic titles. The CONCATENATEX function iterates over a table, evaluates an expression for each row, and concatenates the results into a single string, allowing for custom separators and sorting. This is highly useful for detailed tooltips or lists within a visual.
What You Will Learn
Understand when to use SELECTEDVALUE, CONCATENATEX in a Power BI model.
Practice the concept inside a real PBIX report rather than only reading syntax.
Complete a beginner-level task and verify the result with a hidden answer check.
Practice in Power BI
The starter PBIX link has not been attached yet. The student workflow is ready for the admin to connect the file.
Download and unzip the provided file, then open the 'Tallest Buildings Dynamic Labels.pbix' file.
On Page 1, create a new measure named 'Selected Country Title' using the SELECTEDVALUE function to display the name of the currently selected country from the 'Country' column in the 'Buildings' table.
Assign the 'Selected Country Title' measure to the Title property of the chart visual on Page 1.
Modify the 'Selected Country Title' measure to prepend the phrase "Tallest buildings in " before the country name.
Further modify the 'Selected Country Title' measure to append the count of buildings (using the existing '[Count of Buildings]' measure) after the country name, enclosed in parentheses.
Adjust the SELECTEDVALUE function within 'Selected Country Title' to return the phrase "multiple countries" if more than one country is selected in the slicer.
On Page 2, create a new measure named 'Building List Tooltip' using the CONCATENATEX function. This measure should list the 'Building Name' from the 'Buildings' table, with each name on a new line (use UNICHAR(10) for the new line character).
Assign the 'Building List Tooltip' measure to the Tooltips property of the chart visual on Page 2.
Edit the 'Building List Tooltip' measure to include the 'Height (m)' of each building after its name, in the format 'Building Name (Height m)'.
Refine the 'Building List Tooltip' measure to sort the buildings first by 'Height (m)' in descending order, then by 'Building Name' in ascending order.
Save and close the report.
Starter DAX
Selected Country = SELECTEDVALUE('Buildings'[Country])Expected Outcome
On Page 1, the chart title will dynamically update to show 'Tallest buildings in [Selected Country] ([Count of Buildings])', or 'Tallest buildings in multiple countries ([Count of Buildings])' when multiple countries are selected. On Page 2, the chart tooltip will display a sorted list of building names and their heights, with each building on a new line, like 'Building Name (Height m)'.