Conditional formatting for line charts and legends is GA: colour moves into the model
The Power BI July 2026 update makes conditional formatting for line charts and legends generally available. What it does, where it helps, and the limits to know first.
Line charts have been the odd one out in Power BI for years. You could drive the colour of a column, a bar or a table cell from data, but a line got its colour from the theme or from a manual pick. With the July 2026 update, conditional formatting for line charts and for visuals with legends is generally available, and that gap is finally closed.
It sounds cosmetic, but it means colour can now live in the semantic model as a rule, instead of being clicked into each visual by hand. For teams where several people build reports, that is the real news.
What is now generally available
The feature covers two things.
First, line charts. You can colour lines with a gradient based on the total value of each line, or by the category the line represents. Markers and series labels inherit the conditional formatting until you choose to colour them differently.
Second, visuals with a legend. The July feature summary lists bar charts, column charts, pie charts, donut charts and line charts. When these visuals have a legend, you can conditionally format the colours of the legend categories.
You get the familiar three format styles, all from the fx button next to Color in the format pane:
- Gradient, which maps a numeric field or measure to a colour scale.
- Rules, which assign colours to value ranges.
- Field value, which uses a column or measure that returns a colour, such as a hex code, a CSS colour name or a report theme colour name.
Consistent category colours, defined once
The use case I care most about is consistency. Every report developer has seen the same segment show up blue in one chart and orange in the next, because the colour follows sort order rather than the category itself.
Microsoft's own example fixes this with one measure. If several visuals use Segment as their legend, you colour each segment with a single DAX measure, and every visual shows the same colour for the same category. The documentation uses a measure along these lines:
Segment Color =
SWITCH (
SELECTEDVALUE ( financials[Segment] ),
"Enterprise", "#2CA02C",
"Government", "#9467BD",
"Midmarket", "#FF7F0E",
"#7F7F7F"
)
Apply it with Field value on each chart, and when a colour needs to change, you change the measure once. A colour column in a dimension table works the same way.
A detail worth knowing: if your measure returns theme colour names such as "good" and "bad" instead of hex codes, the colours follow the report theme's sentiment colours. That keeps brand changes in the theme, where they belong.
Line charts get practical patterns
The new documentation walks through several patterns that used to need workarounds or custom visuals:
- Fade prior years. Put Year in the legend, use a gradient on a measure that returns the latest year, and the newest year is shown in blue while older years fade to grey. When the date selection changes, the latest selected year stays highlighted.
- Colour line segments. On a single line, a gradient with a centre value of zero can show negative values in red and positive values in blue. A Segment type setting (Center by default, or Left or Right) controls how each point's colour is applied to the segments next to it, and Shade area adds a shaded area in the same colours.
- Highlight only the extremes. A measure that returns a colour for the minimum and maximum, and a transparent colour for every other point, applied to marker colour, leaves only the two markers that matter.
- Colour by field parameter. Add a colour column to a field parameter table, and the chart keeps a fixed colour for each measure the viewer switches to.
The documentation's sample model is a TMDL script you can apply in Power BI Desktop, which is a quick way to try every pattern without touching a real model.
The limits to know first
The documentation is clear about the edges, and they matter for design decisions:
- Gradient formatting needs a numeric field or measure.
- Field value formatting needs a field or measure that returns supported colour values. For DAX measures, the data type must be text. A calculation group can turn a measure's type into variant, so check this first when formatting does not apply.
- Line segment formatting only works on a single series. Adding a legend creates multiple series and disables segment formatting.
- The field parameter colour approach only works when one parameter option is selected.
- Conditional formatting needs an aggregation or a measure for the field that drives it.
Accessibility is the other limit, and it is on us rather than the product. A grey-to-blue gradient tells a story only if the reader can see it. The documentation itself suggests markers and series labels as non-colour cues. I would treat that as a rule, not a tip.
What to do next
If you maintain a shared semantic model, this is the moment to decide where colour lives. My suggestion:
- Pick the two or three dimensions that appear in legends across most reports, such as segment, region or product line.
- Add a colour column to those dimension tables, or one colour measure per dimension, and document it.
- Prefer theme colour names over hex codes where the theme already defines the colour.
- Update one report as a pilot and check it in light and dark backgrounds, with filters applied.
- Only then roll the pattern into your report template, so new reports start consistent.
Takeaway
After two decades in data, I have learned that report consistency rarely fails on the big things. It fails on small, repeated manual choices like colour. Moving those choices into the model, as rules that every visual reuses, is a quiet but solid improvement.
Which dimension in your reports would you give a fixed colour first?
Sources
Enjoyed this? Get the next one by email
Occasional emails about Microsoft Fabric, SQL Server, Power BI and Synapse.