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.
Hi, I have a line chart with dates on the X-axis, prices on the Y-axis and product names in the legend field.
How can I assign a specific color for each product?
Solved! Go to Solution.
Unfortunately Conditional formatting with line charts isn't possible with the default visual. Best thing to do is ensure your products sort order matches the order of the colours in your Power BI theme, and those are the colours that will be applied to the lines for each product.
I actually just published a blog on something similar: https://excelwithallison.blogspot.com/2023/02/how-power-bi-picks-legend-colours.html
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi @juan_123 ,
Although PowerBI does not currently support conditional formatting for legends, you can manually set different colors for them if you do not have a large number of legends.
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
You might find this interesting.
https://radacad.com/set-power-bi-data-color-all-visuals-to-follow-same-color-for-the-same-data-point
Thanks! I followed all the steps on the link. The thing is that that works fine when you are formatting colors based on the X-axis values. I need to format colors based on the legend field... And there's no option to select a formula for the colors in that case...
Unfortunately Conditional formatting with line charts isn't possible with the default visual. Best thing to do is ensure your products sort order matches the order of the colours in your Power BI theme, and those are the colours that will be applied to the lines for each product.
I actually just published a blog on something similar: https://excelwithallison.blogspot.com/2023/02/how-power-bi-picks-legend-colours.html
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi @AllisonKennedy many thanks for the answer! Hope Power BI adds this functionality. Do you know if there's any custom visual that allows you to set colors from the legend field?
Read your blog, very interesting what you said about the seemingly random colors. Good to know you can set more than just 8 colors in the theme.
Thanks!
Juan
@juan_123 You can vote for the idea on PowerBI Ideas https://ideas.powerbi.com/ideas/ and post the link here for more visibility.
Sorry I dont' know a custom visual off the top of my head that does this, maybe try posting a new question and link to this thread and ask for custom visual suggestions. I know things like Charticulator and Deneb give you lots of custom capabilities so you may be able to form your own visual, but that's a lot of time and learning required. Let me know if you find a good custom visual that works!
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
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 |
---|---|
98 | |
97 | |
85 | |
70 | |
67 |
User | Count |
---|---|
116 | |
109 | |
94 | |
79 | |
72 |