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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Dax for Conditional Formatting KPI not Working

So I have a table of KPI values, all values shown in the matrix 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 of result.

jostho99_0-1651162874740.png

 

 

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try this 

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

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tamerj1
Super User
Super User

Hi @Anonymous 

there is no row context in the marix visual. You need to add the column as a measure perhaps using SELECTEDVALUE and provide the same aggregation in the formatting measure 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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