- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Result is as below.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot. It worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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!: Power BI Cookbook Third Edition (Color)
DAX is easy, CALCULATE makes DAX hard...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
12-10-2024 12:28 AM | |||
09-25-2024 01:56 PM | |||
10-09-2024 05:05 AM | |||
02-07-2025 11:40 PM | |||
01-15-2025 01:29 PM |
User | Count |
---|---|
11 | |
3 | |
3 | |
2 | |
2 |
User | Count |
---|---|
13 | |
6 | |
5 | |
3 | |
2 |