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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Change column color in a bar chart based on a slicer

Hello Everyone,

I have a simple table (Name, Value) , and I have a slicer with Name

Requirement: 

When I select a name, the bar of this name changes its color, like this picture

johndha_0-1654262988142.png

My thoughts are:

1. delete the interaction between the slicer and the bar chart

2.develop a dax formula to get only the selected value ( SelectedValue function won't work as it will get a the same name for each row)

3. this dax will generate 1 only for the selected row and 0 for other rows

4.make color code based on the rule that this function = 1 to be red

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you @amitchandak  this helped alot,

also I developed a calculation with same logic that may help anyone

color 2 = IF(HASonevalue(Names[Name])&&SELECTEDVALUE('Table'[Name]) in VALUES(Names[Name]),"Red","Blue")

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thank you @amitchandak  this helped alot,

also I developed a calculation with same logic that may help anyone

color 2 = IF(HASonevalue(Names[Name])&&SELECTEDVALUE('Table'[Name]) in VALUES(Names[Name]),"Red","Blue")
amitchandak
Super User
Super User

@Anonymous , Create an independent date table with name

 

Names = distinct(Table[Name])

 

then create a color measure and use that in conditional formatting using field value option

 

You can use color name or hex code with prefix #

 

color = if(isfiltered(Names[Name])  && Max(Table[Name])  in allselected(Names[Name]) , "Red", "Blue" )

 

 

PowerBI Abstract Thesis: How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/1682539

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Similar problem that you've answered before.  Want selected column to be a different color.  I followed your instructions, but cannot get only one column to change color based on slicer selection. All columns turn blue or red. 
What I have:

zona_0-1668458918286.png

What I want:

zona_1-1668459191337.png

 

 

 Table 

DISTINCT = distinct('Example'[Letters])

Measure
Colors = IF(ISFILTERED(Example[Letters]) &&
               Max('DISTINCT'[Letters]) in
              ALLSELECTED(Example[Letters]),"Red","Blue")

Please advise what I am doing wrong. Thanks!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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