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
ansa_naz
Continued Contributor
Continued Contributor

How do I ensure theme data colors are applied in a specific order?

Hi all

I have a stacked bar chart, which displays outstanding debt by customer, with a legend for the ageing bucket. The Ageing Bucket categories are:

 

1 - 0 Days

2 - 30 Days

3 - 60 Days

4 - 90 Days

5 - 120 Days

6 - 150 Days

7 - 180 Days

8 - 180+ Days

 

I want the bar chart legend data colors to go from dark green to dark red, left to right. My JSON has the following in the DataColors section:

 

"dataColors": ["#48740f", "#6c9a25", "#89bf36", "#aacc66", "#f2b52c" ,"#D79A12", "#bb7711", "#a11919"],

 

When I import this theme, the data colors are not being applied in left to right order, ie category '1 - 0 Days' to have a colour of dark green, to category '8 - 180+ Days' to have a data colour of dark red:

 

Incorrect Datacolor order for legendIncorrect Datacolor order for legend

 

Visual DataColors settingsVisual DataColors settings

 

Does anyone know how I can ensure the data colours are applied as default in correct order? I have a few other visuals, so I need to make sure they are always applied in the order of the JSON file:

 

1 - 0 Days                     #48740f

2 - 30 Days                   #6c9a25

3 - 60 Days                   #89bf36

4 - 90 Days                   #aacc66

5 - 120 Days                 #f2b52c

6 - 150 Days                 #D79A12

7 - 180 Days                 #bb7711

8 - 180+ Days              #a11919

 

Many thanks for all help

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

hi,@ansa_naz

    After my research, Power BI uses the color along the horizontal of the color-picker, which could avoid two similar colors getting together.

32.PNG

So you can do these follow my steps

Step1:

Add a conditional column in PowerQuery

30.PNG

Step2:

Use group By function

select field Data color and Click Modeling ->Sort by column->Custom

31.PNG

Result:

33.PNG

 

By the way, due to the cache, It will not be effective immediately, you need to save and reopen the pbix.

 

Best Regards!

Lin

Community Support Team _ Lin
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

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi,@ansa_naz

    After my research, Power BI uses the color along the horizontal of the color-picker, which could avoid two similar colors getting together.

32.PNG

So you can do these follow my steps

Step1:

Add a conditional column in PowerQuery

30.PNG

Step2:

Use group By function

select field Data color and Click Modeling ->Sort by column->Custom

31.PNG

Result:

33.PNG

 

By the way, due to the cache, It will not be effective immediately, you need to save and reopen the pbix.

 

Best Regards!

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks! This worked except I had to make a change. In modelling, I selected 'Age Buckets'  field and sorted by 'Custom' column

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.