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.
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
This seems to work great, as here are my color choices, with the theme colors first (the 5 after black and white):
But one of my line charts has some other random colors in it (I'm only showing the legend to protect private data):
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)!
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:
I selected that chart and re-imported the theme file, and it did fix it:
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!
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?
Solved! Go to Solution.
@sturlaws That is fantastic investigative work, and it makes perfect sense. Thank you!
@Anonymous
Check out this thread which tackles the same challenge:
Selecting colours in chart for top 5
Proud to be a Super User!
Paul on Linkedin.
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
@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
@sturlaws That is fantastic investigative work, and it makes perfect sense. Thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |