20. Dynamic Text and Dynamic Colour (Conditional Formatting)
20.8 KPI-based Colouring in Charts and Cards
Bar chart with red bars for slow stores:
Steps in Power BI
- Bar chart: Y-axis = Store Name, X-axis = Avg Delivery Time (mins). There must be no field in Legend (conditional colour is not available with a legend).
- Format visual › Visual › Bars › Colors › click fx next to Default color.
- Format style: Field value ›
[Delivery Time Colour]› OK. Stores slower than 15 minutes turn red. - Analytics › Constant line at 15, labelled "15-min limit".
Other places for fx colours: card Callout value › Color (red Cancellation Rate above a threshold), General › Effects › Background (tint the whole card), Title font colour, line chart Markers, KPI visual colours, button fill, shape fill.
Cancellation Colour = IF([Cancellation Rate] > 0.05, "#D13438", "#107C10") -- 5% is a practice threshold
Platform Colour = SWITCH(SELECTEDVALUE(Orders[Platform]), "Blinkit", "#F2C811", "Amazon Now", "#232F3E", "#8A8886")
Accessibility
Some viewers have colour-vision deficiency, so do not rely on red/green alone. Add icons, labels or patterns, and check the contrast of text on coloured backgrounds (Module 23).
Practice task
(1) Create a dynamic title for the Delivery page showing selected cities and platform. (2) Colour a store bar chart with the delivery colour measure. (3) Add data bars to Total Orders and traffic-light icons to Cancellation Rate in a table. (4) Build a narrative card with Total Orders, Avg Delivery Time and % Under 10 Mins.
Ravindra Bagale's Tip
Friends, many students hard-code thresholds (for example 10 minutes) in several colour measures, then forget to change one of them. Put the target in a single measure or a small targets table, and reference it in every colour rule. Remember this rule.
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students अनेक colour measures मध्ये thresholds hard-code करतात (उदाहरणार्थ 10 minutes), आणि मग त्यातला एखादा बदलायला विसरतात. Target एकाच measure मध्ये किंवा छोट्या targets table मध्ये ठेवा, आणि प्रत्येक colour rule मध्ये त्याचाच संदर्भ द्या. हा नियम लक्षात ठेवा.
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students कई colour measures में thresholds hard-code कर देते हैं (जैसे 10 minutes), फिर उनमें से किसी एक को बदलना भूल जाते हैं. Target को एक ही measure या छोटी targets table में रखो, और हर colour rule में उसी को refer करो. यह नियम याद रखो.
Thodkyaat sangaycha tar (quick recap)
Fx button disla ki to measure ne control karta yeto; zero, ek aani anek selections sathi title test kara; aani colour chi direction (low is good) check kara. Aata pudhe jaauya dynamic charts kade.