Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

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.

 

 

2 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    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 

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Icon for Community Support rankCommunity 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.