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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
DouglasBrito
Helper I
Helper I

Conditional Data Color Formatting Bar by field values

Hi Guys,

 

I'm wondering if it is possible to achieve what I'm looking for.

 

I have a fish quantity dataset through various years, if use [fish qty] as Values with [year] as Axis and [fish name] like Legend (graph 1) on the same year each fish has it own colour. 

 

But the user neeeds a standarized fish colour for each specie (across all pages and visual). So I'm trying to use  DAX to give the color code based on the Fish ID, on the graph 2 if I have 2 species on the same year I can't have to 2 colums color on the same year like the graph 1.

 

Any guess if it is possible to be achieved, as if I filter just one specie the color defined at DAX works fine, but once 2 or more species are chosen just one of the colour is used by the graph.

 

 

Thanks in advance.

 

Douglas

 

 

PBIREport.pngModelExample.png

 

 

 

 

 

 

 

 

 

 

 

 

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

Hi, @DouglasBrito 

 

Thanks for the explanation.
What you want to do is to keep the color of the data bars constant in all cases.

 

The inelegant way to do this is to manually adjust the color of each visual data bar.

vangzhengmsft_0-1637735993893.png


You can also import a custom theme to do this. With custom themes you can customize the color of multiple visual data bars at the same time.
By default, the visuals have their own color groups. If you find inconsistent data bar colors on multiple visuals, it may be that the default colors of different visuals do not match. Or a different theme was applied.

vangzhengmsft_1-1637736040617.png

 

Refer to this document to learn more about custom report themes

Use report themes in Power BI Desktop

You can also make further adjustments to the theme you just imported on your desktop after importing it.

vangzhengmsft_2-1637736122939.png

 

Here is website to help you quickly generate json files for custom themes.

https://themes.powerbi.tips/properties

 

I provide a sample theme below, you can modify it or generate a new theme yourself.

Please refer to the attachment below for details. 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng


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-angzheng-msft
Community Support
Community Support

Hi, @DouglasBrito 

 

Thanks for the explanation.
What you want to do is to keep the color of the data bars constant in all cases.

 

The inelegant way to do this is to manually adjust the color of each visual data bar.

vangzhengmsft_0-1637735993893.png


You can also import a custom theme to do this. With custom themes you can customize the color of multiple visual data bars at the same time.
By default, the visuals have their own color groups. If you find inconsistent data bar colors on multiple visuals, it may be that the default colors of different visuals do not match. Or a different theme was applied.

vangzhengmsft_1-1637736040617.png

 

Refer to this document to learn more about custom report themes

Use report themes in Power BI Desktop

You can also make further adjustments to the theme you just imported on your desktop after importing it.

vangzhengmsft_2-1637736122939.png

 

Here is website to help you quickly generate json files for custom themes.

https://themes.powerbi.tips/properties

 

I provide a sample theme below, you can modify it or generate a new theme yourself.

Please refer to the attachment below for details. 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng


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

DouglasBrito
Helper I
Helper I

Hi @v-angzheng-msft

Thanks for your reply and analysis.

I've added the pbi file by the link below.

 

I need to show fish qty throughout years, I can have multiple species grouped on each year, which is working fine. The problem is, once I choose assign to the Legend the fish id Power automatically assigns a color for each specie.

When it is published these color can change, as PBI service doesn't preserve the desktop color.

The user problem is that he needs to compare fish qty across multiple sites/years. So if fish 1 has the color dark blue, for example, he needs that whenever sites he choose the color is kept. This maybe work fine for the same PBI service session, but if you open a new browser or come back tomorrow to continue your analysis, the fish 1 represented as dark blue can now be displayed as dark orange.

 

So I need to keep the fish color assigned to each fish id immutable. So that id has always the same color.

To do that I cannot just drag the fish id to the Legend, I need to use a conditional formatting based on DAX, which work fine if I have only one specie chosen, once I choose more than one specie it doesn't work, as DAX return just one hex color code.

 

I hope I have made it a bit clear.

 

 

Thanks,

https://drive.google.com/file/d/1bN2dJYay7nkpiAxi6xRi5EHVg2wiLVev/view?usp=sharing 

 

 

 

 

 

 

v-angzheng-msft
Community Support
Community Support

Hi, @DouglasBrito 

 

Is graph 2 a stacked column chart? Do you want graph 2 to have different colors as graph 1?
Try to add a legend field to the stacked column chart.

vangzhengmsft_0-1637718146435.png

If this doesn't work, please consdier sharing more details about it and posting expected result so it is clear on what needs to be implemented?  And It would be great if there is a sample file without any sesentive information here.

It makes it easier to give you a solution.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors