20. Dynamic Text and Dynamic Colour (Conditional Formatting)
20.2 Dynamic Titles with Measures
Steps in Power BI
- Create the measure (below) with Home › New measure. It must return text.
- Select the chart › Format visual › General › Title › Text › click fx.
- Format style: Field value; What field should we base this on?:
[Title Orders by City]› OK. - Change the Platform and Month slicers. The title changes, e.g. "Blinkit orders by city – Oct 2025".
Selected Platform = SELECTEDVALUE(Orders[Platform], "All platforms")
Title Orders by City =
VAR p = SELECTEDVALUE(Orders[Platform], "Blinkit + Amazon Now")
VAR m = IF(HASONEVALUE('Date'[Year Month]), FORMAT(MAX('Date'[Date]), "mmm yyyy"), "selected period")
RETURN p & " orders by city – " & m
SELECTEDVALUE(column, alternate) returns the value when exactly one is selected, otherwise the alternate text.
Samjla ka? Selection nasel, ek asel, anek astil – tinhi case test kara.
Ravindra Bagale's Tip
Mitrano, dhyan dya: A dynamic title that shows "Sales for Pune" when nothing is selected is misleading. Handle the "no selection" and "multiple selection" cases in the measure, udaharan mhanje with SELECTEDVALUE(DarkStore[City], "All cities"). Test the title with zero, one and several cities selected. Chuk karu naka!