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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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