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
Friends, pay attention: 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, for example with SELECTEDVALUE(DarkStore[City], "All cities"). Test the title with zero, one and several cities selected. Don't make this mistake!
Ravindra Bagale's Tip – मराठी
मित्रांनो, लक्ष द्या: काहीच select केलेलं नसताना "Sales for Pune" दाखवणारा dynamic title दिशाभूल करतो. Measure मध्ये "no selection" आणि "multiple selection" हे cases handle करा, उदाहरणार्थ SELECTEDVALUE(DarkStore[City], "All cities") ने. शून्य, एक आणि अनेक cities select करून title test करा. ही चूक करू नका!
Ravindra Bagale's Tip – हिंदी
दोस्तों, ध्यान दो: कुछ भी select न होने पर "Sales for Pune" दिखाने वाला dynamic title गुमराह करता है. Measure में "no selection" और "multiple selection" वाले cases handle करो, जैसे SELECTEDVALUE(DarkStore[City], "All cities") से. शून्य, एक और कई cities select करके title test करो. यह गलती मत करना!