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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
v-rzhou-msft
Community Support
Community Support

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

 


 

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
Super User
Super User

@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?


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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