Reply
swapnilrlabhe
New Member

Dynamic Colors for Line Chart

We have a PBI report which shows the Year wise data on line chart . This data have assigned colors for each Year showing data. The issue we are facing ,whenever year changes on 01/01 of every year the line chart pops up data with new year and picks random color. This has required a manual intervention to go and assign the color as per pour company standards .

To avoid this manual change and keep it dynamic, need expertise to check whether there is any workaround/way in PBI where we can define the color codes on line charts for all upcoming years say next 50 years . 

So that whenever new year data pops in, PBI Line chart picks the color we already defined for that year.

For ex:- on 01/01/2025 for Year 2025 new line will appear in chart with randomly picked color by PBI.

But we wanted to define it now before 12/31/2024 so that on 01/01/2025 it shows the color we defined already instead picking it randomly from pallet.

Suggestions are welcome

1 ACCEPTED SOLUTION
v-jtian-msft
Community Support
Community Support

Hi,Arul ,thanks for your concern about this issue.
And I would like to share some additional solutions below.

Hello,@swapnilrlabhe .I am glad to help you.
For your needs, the general solution is to set the conditional format, and for each year of data, set the corresponding color for it separately (based on the value of MEASURE)
URL:
Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

The problem is that this way is limited to some types of Visuals, for other Visuals where you can't set conditional formatting, if you want to set a specific display color for each year. As I understand it, the order of the color settings is based on the default order of the colors in the Theme you are currently setting up.
Like this:

vjtianmsft_1-1729843204768.png

 

Here is the issue and the official documentation.
URL:
Solved: How are theme colours assigned to series on a line... - Microsoft Fabric Community
Use report themes in Power BI Desktop - Power BI | Microsoft Learn
 

vjtianmsft_2-1729843224392.png

I've noticed that the color settings in the Theme seem to be limited to the first eight by default, here's my suggestion to you
You can contact your team members to define a Theme file (JSON file)
and set the color order of your implementation in it, and then use your own Theme, so that when power bi applies the member colors, they will be applied individually in the color order written in the file.
like this:

There are also some Theme File examples in the official documentation, hopefully they will help you.

{
"name": "Themetest",
"dataColors": ["#003B64", "#FFF200", "#FFD500", "#A9E0EA", "#231F20", "#49494A", "#737474", "#9A9B9B", "#C3C4C4", "#E7E7E7", "#FFFFFF"],
"background":"#FFFFFF",
"foreground": "#A9E0EA",
"tableAccent": "#FFD500"
}

Note that this is only an example, you will need to contact a member of your team who is proficient in front-end page design to collaborate on the Theme file.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jtian-msft
Community Support
Community Support

Hi,Arul ,thanks for your concern about this issue.
And I would like to share some additional solutions below.

Hello,@swapnilrlabhe .I am glad to help you.
For your needs, the general solution is to set the conditional format, and for each year of data, set the corresponding color for it separately (based on the value of MEASURE)
URL:
Apply conditional table formatting in Power BI - Power BI | Microsoft Learn

The problem is that this way is limited to some types of Visuals, for other Visuals where you can't set conditional formatting, if you want to set a specific display color for each year. As I understand it, the order of the color settings is based on the default order of the colors in the Theme you are currently setting up.
Like this:

vjtianmsft_1-1729843204768.png

 

Here is the issue and the official documentation.
URL:
Solved: How are theme colours assigned to series on a line... - Microsoft Fabric Community
Use report themes in Power BI Desktop - Power BI | Microsoft Learn
 

vjtianmsft_2-1729843224392.png

I've noticed that the color settings in the Theme seem to be limited to the first eight by default, here's my suggestion to you
You can contact your team members to define a Theme file (JSON file)
and set the color order of your implementation in it, and then use your own Theme, so that when power bi applies the member colors, they will be applied individually in the color order written in the file.
like this:

There are also some Theme File examples in the official documentation, hopefully they will help you.

{
"name": "Themetest",
"dataColors": ["#003B64", "#FFF200", "#FFD500", "#A9E0EA", "#231F20", "#49494A", "#737474", "#9A9B9B", "#C3C4C4", "#E7E7E7", "#FFFFFF"],
"background":"#FFFFFF",
"foreground": "#A9E0EA",
"tableAccent": "#FFD500"
}

Note that this is only an example, you will need to contact a member of your team who is proficient in front-end page design to collaborate on the Theme file.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Arul
Super User
Super User

@swapnilrlabhe ,

Are you using year in Legend field?





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

Proud to be a Super User!


LinkedIn


yes

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)