Forum Discussion
Conditional Formatting with a Legend
- 4 months ago
Hi 0Experience
Thank you for the thorough explanation. Currently, in Power BI, when a visual uses a legend for multiple series, the legend determines the color assignment for each series. As a result, conditional formatting for data colors using DAX measures or field values may not be available, as it is overridden by the legend.See this reference: https://learn.microsoft.com/en-us/power-bi/visuals/power-bi-visualization-conditional-formatting#co…
For cases where you need consistent colors across visuals and pages, using a Report Theme (JSON) is recommended. This approach centralizes the color palette and helps maintain consistency, though colors are assigned based on the series order and may change if legend values are filtered.
If you need fully dynamic, data-driven color control while keeping the legend (including in Focus Mode and exports), native Power BI visuals do not currently support this. In such situations, a custom visual like Deneb can be used to explicitly map colors and retain a functional legend.
Reference:https://learn.microsoft.com/en-us/power-bi/create-reports/report-themes-create-custom
If you have any further questions, feel free to reach out and we'll be glad to assist.
Regards,
Microsoft Fabric Community Support Team.
Hi,
In Microsoft Power BI, conditional formatting of column/bar colours only works when a Legend is not used. If you remove the legend, you can fully control the colours using a measure or rules.
Steps to Apply Conditional Formatting Without a Legend
- Remove the Legend field from the visual.
- Create a colour measure that returns a colour code based on your logic.
Colour Measure =
SWITCH(
SELECTEDVALUE('Table'[Country]),
"Brazil", "#1f77b4",
"Germany", "#2ca02c",
"Japan", "#ff7f0e",
"USA", "#9467bd",
"#cccccc"
)
- Select the visual → Format pane → Data colours.
- Click the fx (conditional formatting) button.
Choose:
- Format style: Field value
- Based on field: Colour Measure
This will dynamically apply colours to the bars based on your logic.
Additionally,
If you still want users to understand the categories without a legend, you can:
- Enable Data labels
• Show the category field on the axis
• Add a separate legend visual or text explanation on the report
This approach allows you to maintain dynamic colour control while avoiding the limitation that occurs when a legend is present.
Hope this helps.
Thanks!
- 0Experience5 months agoHelper III
SamInogic thanks for your answer.
I can’t use a separate legend visual or text explanation in the report because, when a user switches to focus mode or takes a screenshot, that separate legend/explanation will not appear in the screenshot.