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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Dynamic Conditional Formatting of Clustered Bar Chart

Hello, I'm using the following methods to filter and make the bar chart a different color for one bar and neither are working. 

Method 1:

- Create the measure
BAR COLOR = IF(SELECTEDVALUE(Table[SchoolName Format])
=('Table2'[School])),1,0)
- Select bars ->fx -> rules if 1 then blue if 0 then grey
 
Method 2:
-Create the measure
BARColoralternate =
var _Selectedschool =  VALUES('Table'[ID])
Var _Schooltohighlight =
    SELECTEDVALUE('Table2'[ID])
Var _Filtered =
    ISCROSSFILTERED('Table'[ID])
           var _result=
    SWITCH(TRUE,not ((_Filtered)), "grey", _Schooltohighlight in _Selectedschool && _Filtered, "grey", "Blue")
    return _result
-Select bars -> fx -> Field Value ->Measure
 
I've scoured the internet with no solution. I put the data in a table to verify. The table shows that one value has the correct color and the other values are the default color, but it is not showing on the bar chart. Help. 
2 REPLIES 2
Padycosmos
Solution Sage
Solution Sage

You may try something similar to the following:

Here && is for AND and || is for OR

 

Colour = SWITCH(TRUE(),
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"keyboard")&&
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"belkin"),"Pink",
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"drive")||
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"trackball"),"Limegreen",
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"keyboard"),"Red",
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"pad"),"Yellow",
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),"mouse"),"Aqua",
CONTAINSSTRING(SELECTEDVALUE(Orders[Product Name]),""),"Grey")
Anonymous
Not applicable

That is hard coding the values and will not work. I'm looking for the bar chart to change 1 bar color based on the user-selected value in a slicer. For example, If the value = user selected value then blue else grey. I used this logic in the bar chart and it did not work. I don't know why.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors