Line Segment and Legend Color Based on Measures
Conditional formatting in Power BI just got a solid upgrade.
In the July 2026 update, conditional formatting now works on Line Charts and visuals with Legends. This was one of the most requested features. It lets you apply data-driven colors across multiple visual types and keep colors consistent throughout your reports.
Up until recently, when I used to interview Power BI professionals with a lot of experience in visualization, I had a good way to test them.
I'd ask one of these questions:
- Which visuals don't support conditional formatting?
- I made some changes to my visual and now the conditional formatting option isn't showing. Why?
- How do you apply conditional formatting on Line and Pie visuals?
It was an easy way to catch gaps. Conditional formatting wasn't supported on legends. For Pie visuals, the workaround was to apply it on a Bar chart first and then switch to Pie. For Line visuals, we used to get extra color markers the same way.
Power BI has been improving its visualization experience steadily over the last two years, with big updates coming regularly. This long-awaited feature finally made it into the July 2026 update. Conditional formatting is now supported on Line visuals and Legends.
Why it was needed on Line visuals
Just like any other visual, you sometimes need line segments to change color based on a condition. This helps explain things like margins going down or current year vs previous year comparisons.
Why it was needed on Legends
Say your company always uses one color and your competitor uses another. On a report showing market share, you'd always want your company represented by the same color. That was possible for axis values but not for legends. This update fixes that. You can now apply conditional formatting on Pie, Stacked, and any other visual that uses a legend.
Please find the file where I have used different measures to do conditional formatting on Line and Legends
Measure used
Brand Color = SWITCH ( TRUE (), Max('Item'[Brand])= "Brand 1", "Yellow", Max('Item'[Brand])= "Brand 2", "Green", Max('Item'[Brand])= "Brand 3", "Blue", Max('Item'[Brand])= "Brand 4", "Red", Max('Item'[Brand])= "Brand 5", "Orange", Max('Item'[Brand])= "Brand 6", "Purple", Max('Item'[Brand])= "Brand 7", "Pink", Max('Item'[Brand])= "Brand 8", "Cyan", Max('Item'[Brand])= "Brand 9", "Lime", Max('Item'[Brand])= "Brand 10", "Brown", Max('Item'[Brand])= "Brand 11", "Gray", Max('Item'[Brand])= "Brand 12", "Teal", Max('Item'[Brand])= "Brand 13", "Magenta", "Other" )
Category Measure
Category Color = SWITCH ( TRUE (), Max('Item'[Category] )= "Category 1", "Red", Max('Item'[Category] )= "Category 2", "Green", Max('Item'[Category] )= "Category 3", "Blue", Max('Item'[Category] )= "Category 4", "Yellow", Max('Item'[Category] )= "Category 5", "Orange", "Black" )
Color Year
Max Year = max('Date'[Year])
You can also check the video on the same -
https://www.youtube.com/watch?v=SDX1gUpcJaw&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L&index=1