powerbi - Power BI Create colouring on bar chart depending on conditions of a column and the count - Stack Overflow

admin2025-04-18  3

I am looking for help to create colouring on a bar chart depending on certain conditions. I have a bar chart which displays the column Performance. The values in this column are categories. The graph shows the grand total count (%) of each category.

Bar Char

I would like to do conditional formatting colouring on the bars with the following conditions:

Meets Expectations is colour orange when, Meets Expectations + Exceeds Expectations > 90

Marginal is coloured yellow when, Marginal + Below Expectations > 40

Exceeds is coloured green when, Exceed Expectations > 30

Below is coloured red when, Below Expectations> 15

Since I am doing a grand total count of each category, I have tried to create measures for each performance category to count the grand total, but realized this does not work as it will not take the other measures into account. This is what I did:

I created this conditional formatting measure

Conditional Formatting Measure = 
Switch(TRUE(),
SELECTEDVALUE('Aggregate'[PerformanceLevel]) = "Meets " && [Meets%]+[Exceeds%] > 90, 
"orange",
SELECTEDVALUE('Aggregate'[PerformanceLevel]) = "Marginal" && [Marginal%] + [Below%] > 40, 
"yellow", 
SELECTEDVALUE('Aggregate'[PerformanceLevel]) = "Exceeds" && [Exceeds%] > 30, "green", 
SELECTEDVALUE('Aggregate'[PerformanceLevel]) = "Below" && [Below%] > 15, "red",  "grey")

Where [Exceeds%], [Meets%], [Marginal%], [Below%] are measures I created to try to capture the grand total % count.

The calculations I used for each were similar:

Exceeds% = [Count ExceedExpectations]/
COUNTROWS(FILTER(ALLSELECTED('A Table'),'A Table'[PerformanceLevel] IN {"Below 
Expectations","Marginal","Meets Expectations","Exceed Expectations" }))*100

After doing this and testing, I realized by doing the separate measures for each performance category, it was not taking the other categories into account. When I tried to sum them in the conditional formatting measure, one of them would be counted as 0. Perhaps I am overcomplicating and there is a much simple way to do this.

This is a link to sample workbook: Link to google drive

How can I do this? I would appreciate any guidance and help. Thank you

转载请注明原文地址:http://www.anycun.com/QandA/1744954040a89969.html