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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Can't control color of bars on simple "top 5" chart

I have a problem that has to be so simple, it's making me crazy. I have a "top 5" bar chart and need to show the same 5 colors all the time, no matter what the 5 values are. So I can't hard-code the colors, as the top 5 are from a huge list and we never know what the top 5 will be.

 

In this article about report themes it seems pretty clear that setting dataColors in the theme file should give me what I need: 

dataColors: The list of color hexadecimal codes to use to color shapes that represent data in Power BI Desktop visuals. This list can have as many or as few colors as you want. Once all colors from this list have been used, if the visual still needs more colors, it reverts back to using Power BI’s default color palette.

 

So my theme file has the 5 colors I need listed first - I've confirmed these are correct, it's yellow, blue, black, green, and red

theme colors.png

 

 

 

This seems to work great, as here are my color choices, with the theme colors first (the 5 after black and white):

theme color menu.png

 

But one of my line charts has some other random colors in it (I'm only showing the legend to protect private data):

legend 1.png

 

I tried clicking "revert to default" in my data colors, and nothing changed. So I tried re-importing the theme file while I had the chart selected, hoping that might work. It did (at first)!

fixed legend.png

 

So then I looked at my second chart on a different page, it's the exact same chart, only displayed much larger. It should have the same colors, but doesn't:

bad legend 2.png

 

I selected that chart and re-imported the theme file, and it did fix it:

fixed second.png

 

And now, I go back to my original chart which had been fixed when I re-imported the theme file the first time, and IT'S BROKEN AGAIN!

BROKEN AGAIN.png

 

And of course, to top it off, when I change my filters and display new data, BOTH CHARTS ARE BROKEN AGAIN.

 

This should be so simple. Can someone please help?

2 ACCEPTED SOLUTIONS

Hi ,
 
when using the TopN-filter, the items in the legend seems to be assigned a color, even if they are not shown. Here are two visuals, using the exact same data, except the bottom one has a TopN-filter on the lenght of the country name.
 

 
As you can see, the colors assigned to each country in the bottom visual are exactly the same colors these countries have in the upper visual(e.g. Australia is green and England is dark blue). So pretty sure this is what you are experiencing. 
 
I tried some variations on filtering out items so they would not be assigned a color, but no luck. Seems like the only option is to use conditional coloring.

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

Anonymous
Not applicable

@sturlaws That is fantastic investigative work, and it makes perfect sense. Thank you!

View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

@Anonymous 

 

Check out this thread which tackles the same challenge:

Selecting colours in chart for top 5 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






v-shex-msft
Community Support
Community Support

HI @Anonymous,

I think you are misunderstanding with theme data color property.  If you enable a theme in power bi report, power bi will use these colors that you define in theme with a high priority.
It does not mean power bi will use force use specific index or sorting orders to setting data label colors. (defined data color sets does not contain property to store index or sorting orders)

If you want setting data label with specific data color, I'd like to suggest enabled conditional formatting with color fields.

Use conditional formatting in tables 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@v-shex-msft Thank you for the quick reply. I'm just trying to figure out what this wording means, if I'm misunderstanding it:

 

"Once all colors from this list have been used, if the visual still needs more colors, it reverts back to using Power BI’s default color palette."

 

It seems clear that the colors it chooses come from the list in the custom pallette, and once it runs out of those, it goes back to using default colors. If those words don't mean what they say, can you please explain what they do mean? I have 5 bars in my chart and more than 5 colors in my theme, so there would never be a need to revert back to default colors. Why would it revert back to them before using all the theme colors?

 

"It does not mean power bi will use force use specific index or sorting orders to setting data label colors"

I'm not asking it to, I just want it to behave as the documentation describes. I'm not trying to complain here, I just want to understand the meaning of the documentation, or suggest it be updated to describe the true behavior, since it doesn't behave as it says it should.

 

Thank you for the other link as well, I'll check that out and hopefully either that or the post below helps me find the solution.

 

thanks!

Alex

Hi ,
 
when using the TopN-filter, the items in the legend seems to be assigned a color, even if they are not shown. Here are two visuals, using the exact same data, except the bottom one has a TopN-filter on the lenght of the country name.
 

 
As you can see, the colors assigned to each country in the bottom visual are exactly the same colors these countries have in the upper visual(e.g. Australia is green and England is dark blue). So pretty sure this is what you are experiencing. 
 
I tried some variations on filtering out items so they would not be assigned a color, but no luck. Seems like the only option is to use conditional coloring.

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Anonymous
Not applicable

@sturlaws That is fantastic investigative work, and it makes perfect sense. Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.