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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
msommerf
Helper III
Helper III

Conditionally format bar chart column colour based on slicer value

I have the following visuals:

Bar colours in BI.png

 

I am looking to change the colour of each bar based on the selection of the Depot slicer.

If depot slicer is Depot 1, the Depot 1 bar is highlighted

If depot slicer is Depot 2, the Depot 2 bar is highlighted

 

Can anyone advise if this is possible with a measure and conditional formatting?

 

Any assistance appreciated.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @msommerf ,

 

Try this:

 

1. Create a separate Depot table.

Depot = VALUES ( 'Table'[Depot] )

 

2. Create a Measure like so:

Highlight = IF ( MAX ( 'Table'[Depot] ) = SELECTEDVALUE ( Depot[Depot] ), "Yellow", "Blue" )

 

3. Set conditional formatting of Data color in Clustered column chart.

 

data color.jpg

data color2.jpg

 

4. Test.

data color.gif

For more details, please check the attached PBIX file.

 

 

Best Regards,

Icey

 

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

4 REPLIES 4
Icey
Community Support
Community Support

Hi @msommerf ,

 

Try this:

 

1. Create a separate Depot table.

Depot = VALUES ( 'Table'[Depot] )

 

2. Create a Measure like so:

Highlight = IF ( MAX ( 'Table'[Depot] ) = SELECTEDVALUE ( Depot[Depot] ), "Yellow", "Blue" )

 

3. Set conditional formatting of Data color in Clustered column chart.

 

data color.jpg

data color2.jpg

 

4. Test.

data color.gif

For more details, please check the attached PBIX file.

 

 

Best Regards,

Icey

 

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

Hi 

That's fantastic. Is there any way to change the format the axis labels using the slicer in the same way? I want to be able to only show the label of the selected column by changing the font colour of the other labels to white. I tried it in your example file by changing the conditional formatting of the X axis value settings but the only effect was that all three labels changed to yellow when I select Depot 3, they all remained blue when selecting Depot 1 or Depot 2. I guess this is something to do with the Max function in the Highlight measure. It's odd that the conditional formatting behaves differently for different elements in the same chart.

Many thanks

Nigel

Hey Icey, I've implemented your solution and it works great! Thank you for that. I do however have a question. Is it possible to use the slicer as a filter for other visuals? In my model I get a circular reference error when trying to make the relationship. 

 

Thank you!

ZL

amitchandak
Super User
Super User

Create a measure like this

Color Measure = if(Max(Table[Depot] in allselected(Table[Depot])) <today(),"Yellow","Blue")

 

And use field options and measure in conditional formatting

https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.