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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
sfernamer
Helper III
Helper III

How to fix colors for stacked bars values

Hi everyone!

 

I would like to ask you if there is any way with DAX to fix the colours of the stacked bar visualization. I know where is the menu and how to change the colors but the problem is a bit deeper:

 

The values of Situation column (FastBreak, Not Defined, Pick & Roll, With Ball and Without Ball) can change (and have other ones like OFF Screen) because the visualization shows the values for a specific date (the MAX Date) so, if a Situation value is not registered in MAX(Date), we can't see it on the visualization.

 

Is there any way to fix every value with a specific colour?

 

Thank you in advance. 

 

 

Test1.png

3 REPLIES 3
sfernamer
Helper III
Helper III

Hi @johncolley ,

 

Firstly, thank you for your reply. I was trying to create the measure as you texted me but, after creating it, I don't have the option to add the measure to any of the Stacked Bar options.

 

Additionally, bearing in mind it's a stacked bar chart, I don't have the option to go to the Color side and determine the colour based on a formula. 

 

Could you tell me, please, where should I add the measure once created?

 

Add you an image with the measure created.

 

Thank you for your time. Look forward to your reply.

 

Test2.png

Hi @sfernamer ,

 

Currently in Power BI you can't use the legend field and conditional formatting. If you were to remove the legend an option would appear for you to conditionally format the visual.

 

As workarounds you can try the solution here: https://www.youtube.com/watch?v=OC7pgwF6ID8 or try a custom visual such as the 'xViz multiple axes chart' which allows conditional formatting and a legend.

 

You can also vote for this idea for the functionality to be included in power bi: https://ideas.powerbi.com/ideas/idea/?ideaid=3b2cf504-d893-eb11-8ced-501ac50a6edb

 

If this answer solves your problem please mark it as a solution!

johncolley
Solution Sage
Solution Sage

Hi @sfernamer ,

 

There is 2 ways you can address this:

 

1. Alter the filters on the visual so all categories are showing then set the colours - these selections will stay even when you filter to a specific date.

 

2. Set the colours with a measure:

Bar colour = 
Var _situation = SELECTEDVALUE (table[situation])
Var _result = SWITCH(TRUE(),
_situation = "Fastbreak", "Pink",
_situation = "Without Ball", "Yellow"
etc. )
RETURN
_result

You can also set the colours in the measure with a # value e.g #002060 for specific colours.

 

If this answer solves your problem please mark it as a solution!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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