Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
0Experience
Helper III
Helper III

Conditional Formatting with a Legend

Hi everyone,


I’m hoping to get some ideas from the community.


As many of you know, when a visual uses a legend, Power BI doesn’t allow us to apply conditional formatting (from a table or measure) to control the column colors. I can apply conditional colors when there’s no legend.

 

0Experience_0-1772641778862.png


I have multiple report pages, each containing several visuals, and manually adjusting the colors across all of them is becoming extremely time‑consuming.

Is there any way to apply conditional formatting to column colors while still using a legend?


Or, if that’s not possible, do you have any alternative approaches or best practices that could help make this easier to manage?


I’ve attached the Power BI file as well if anyone wants to take a look or experiment with it.


Thanks in advance for any suggestions.

1 ACCEPTED SOLUTION

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.

View solution in original post

12 REPLIES 12
v-karpurapud
Community Support
Community Support

Hi @0Experience 

Just checking in as we haven't received a response to our previous message. Were you able to review the information above? Let us know if you have any additional questions.

Thank You.


Ryan_Pat
Frequent Visitor

Hi @0Experience 

Could you please mark the answer as verified if it meets your expectations? Once it is marked as verified, this forum thread can be closed.

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.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





@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.

 

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.

@Ryan_Pat I am still looking for an answer because the previous responses did not meet my expectations. I’m also not sure whether the problem I have or the solution I’m seeking is actually feasible or possible.

v-achippa
Community Support
Community Support

Hi @0Experience,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @MFelix and @SamInogic for the prompt response.

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.

 

Thanks and regards,

Anjan Kumar Chippa

@v-achippa 

No, the solutions provided unfortunately did not meet my expectations. Thank you for checking, though.


SamInogic
Solution Sage
Solution Sage

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!

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

@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.

MFelix
Super User
Super User

Hi @0Experience ,

 

The colors are set based on the theme  so when you select a specific field the values will have the same color based on the order of the colors selected in this case you are using the base theme for Power BI so when you select the country it will apply the same color consistently to the 1st, 2nd, and so on.

 

MFelix_0-1772651007027.png

 

The problem occurs when has you refer apply the legend and then the colors are repeated even when you select different column categories:

MFelix_1-1772651096293.png

Depending on what type of visual you are using you can change this in order to get the condittional formatting.

 

For example in the case the you show you can make a concatenation of the x-axis instead of using the legend and in that case you can then use the condittional formatting using a table with the expected colors.

 

Check the video below:

https://www.youtube.com/watch?v=-FG0DSSAr60

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





@MFelix thanks for your detailed reply and for the examples. Really appreciate it.

 

However, I don't want to use the concatenation of the x-axis

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.