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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Conditional Formatting for target on KPI

So I have a table of KPI value, all values shown below are the average of the result. For my target calculation I have a switch case as such: 

 

Targets = 
SWITCH(
    TRUE(),
    'Table'[MetricName] = "Days to Containment" && AVERAGE('Table'[Result]) > 10, "Red",
    'Table'[MetricName] = "Days to Containment" && AVERAGE('Table'[Result]) > 10, "Red",
    "Green"
)

 

Targets is a calculated column. In this program I am saying if the average result of a specific column name is greater than 10 then it is red if not it is green. Why does it show green for all values? I have tried it with and without the average around result.

jostho99_1-1651101813955.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your code, I think [Target] is a calculated column. Here I suggest you to create a measure instead of calcualted column for conditional formatting. And there are not many conditions and return values in parallel here, only green and red. So I suggest you to try IF function.

My Sample:

RicoZhou_0-1651474849774.png

Measure:

Targets =
IF (
    MAX ( 'Table'[MetricName] ) = "Days to Containment"
        && AVERAGE ( 'Table'[Result] ) > 10,
    "Red",
    "Green"
)

 

RicoZhou_2-1651475051082.png

 

Result is as below.

RicoZhou_1-1651475030681.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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your code, I think [Target] is a calculated column. Here I suggest you to create a measure instead of calcualted column for conditional formatting. And there are not many conditions and return values in parallel here, only green and red. So I suggest you to try IF function.

My Sample:

RicoZhou_0-1651474849774.png

Measure:

Targets =
IF (
    MAX ( 'Table'[MetricName] ) = "Days to Containment"
        && AVERAGE ( 'Table'[Result] ) > 10,
    "Red",
    "Green"
)

 

RicoZhou_2-1651475051082.png

 

Result is as below.

RicoZhou_1-1651475030681.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.

 

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.