Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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.
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.
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.
Thanks a lot. It worked
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
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.
@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?
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
3 | |
3 | |
2 | |
2 |