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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Kavya123
Helper III
Helper III

Conditional color coding in Bar chart

Hi Everyone,

I need to apply condition in bar chart for color coding.  I need output like below screenshot. 

ID 1 is having four desc values. The Company ID 100 is associated with desc value 'AAA' for ID 1 . If I select company ID 100 and ID 1 then I should get all four desc bars and the bar 'AAA' should highlight in red color. Please help me to achieve this in bar chart.

This is the sample data.

Company ID , ID, Desc

100,1,AAA

200,1,BBB

300,1,CCC

400,1,DDD

100,2,EEE

200,2,FFF

300,2,GGG

 

Kavya123_1-1628864862131.png

Thanks in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Kavya123 

This issue should be caused by Max function in color measure, it will always catch the max Company ID in same Desc. So when you have 100 and 200 in AAA(Desc) in 1(ID), only click 200 will show red. Try values function to get Company ID in Data Table. The new measure is as below.

Color Measure 1 = 
VAR _SELECTCompanyID = SELECTEDVALUE('Company ID'[Company ID])
VAR _VALUES= VALUES('New Table'[Company ID])
RETURN
IF(_SELECTCompanyID IN _VALUES,"Red","Yellow")

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @Kavya123 

I think you need to build an unrelated Company ID table to create the slicer to achieve your goal. If you use Company ID column in the same table, your color measure will disable, due to all Company IDs are selected all the same. 

Unrelated Company ID table:

Company ID = 
VALUES('Table'[Company ID])

Measure is as below.

Color Measure = 
VAR _SELECTCompanyID = SELECTEDVALUE('Company ID'[Company ID])
RETURN
IF(MAX('Table'[Company ID]) = _SELECTCompanyID,"Red","Yellow")

Find Data color in Format, click fx, format by field value and select this color measure.

1.png

Result is as below.

2.png

Best Regards,
Rico Zhou

 

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

 

Thanks a lot. It worked

Hi Ricozhou,
 
Thanks for your response. In my case few descriptions are repeating. It is working for Company Id 200 and for company ID 100 color is not changing.

Company ID , ID, Desc

100,1,AAA

200,1,AAA

300,1,DDD

400,1,DDD

100,2,EEE

200,2,FFF

300,2,GGG

 
Kavya123_1-1629200163096.png

 

Kavya123_3-1629200209217.png

 


 

Anonymous
Not applicable

Hi @Kavya123 

This issue should be caused by Max function in color measure, it will always catch the max Company ID in same Desc. So when you have 100 and 200 in AAA(Desc) in 1(ID), only click 200 will show red. Try values function to get Company ID in Data Table. The new measure is as below.

Color Measure 1 = 
VAR _SELECTCompanyID = SELECTEDVALUE('Company ID'[Company ID])
VAR _VALUES= VALUES('New Table'[Company ID])
RETURN
IF(_SELECTCompanyID IN _VALUES,"Red","Yellow")

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

 

Greg_Deckler
Community Champion
Community Champion

@Kavya123 Are you slicers and bar chart columns all coming from the same table? If so then do you have interactions turned off between the slicers and the bar chart?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi,

Thanks for your response. Yes slicers and bar chart columns all coming from the same table.

This is the sample data.

Company ID , ID, Desc

100,1,AAA

200,1,BBB

300,1,CCC

400,1,DDD

100,2,EEE

200,2,FFF

300,2,GGG

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.