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 0Experience ,
One question to try and give you some work around, I believe that your example is not matching your model setup, when youn refer that you want to keep consitency across the pages is it fpor a particular dimension, or is it for all the calculations?
Do you have a lot of values on your dimension table that you are using for legend or are only a few values?
Can you please elaborate a little bit more on your semantic model setup and expected outcome.
MFelix thank you again.
I have a total of 11 countries in my legend, and they are all connected to a filter/slicer. When I use the countries in the legend, Power BI automatically assigns colors to them, but I don’t want to use those default colors. I need to apply specific colors, which I am currently setting manually. Since my report has 20 pages and each page contains around 15 visuals, manually adjusting colors is extremely time‑consuming and not a good practice.
My goal is to assign colors from a DAX/table instead. However, if I remove Country from the legend, then I can apply the colors from the DAX/table, but I lose the legend entirely. As a workaround, I could place a separate visual on each page to display the country colors as a legend, but this approach has a limitation: when users switch a visual into Focus Mode or take a screenshot, the separate legend visual will not appear.
Additionally, the X‑axis varies across visuals. For example, some visuals use Gender (male, female, non‑binary), while others use Area Type (urban, rural). The number of X‑axis categories changes from one visual to another, sometimes as few as 2 and sometimes up to 20.
- v-karpurapud4 months agoCommunity Support
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.