Forum Discussion

Easter-J's avatar
Easter-J
New Member
1 year ago
Solved

Help with a DAX Measure and Conditional Formatting

Hi! I am trying to write a DAX measure to use in a matrix to apply conditional formatting.   The row I want to highlight looks like this   I want to highlight the value 4.37 using the follo...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Easter-J 

    Thanks for reaching out on the Microsoft Fabric Community Forum,

    As vicky_  suggested, try using the MAX function instead of SELECTEDVALUE. This approach is more stable, especially when your matrix is aggregating values.

    Here’s a revised version of your measure using MAX, with a green highlight as you requested.

    Highlight Color =

    VAR _id = SELECTEDVALUE('Voluntary 2s Removed'[Id])

    VAR _rate = MAX('Voluntary 2s Removed'[Rate]) -- You can also use AVERAGE or MIN depending on your needs

    RETURN

    SWITCH(TRUE(),
    _id = "8.1.12" && _rate >= 2.90, "#A9DFBF",  -- Green

    _id = "1.1.2" && (_rate <= 3.50 || _rate >= 4.50), "#F9E79F",  -- Yellow

    "#FFFFFF"  -- Default white)

    If your matrix is aggregating values, replacing SELECTEDVALUE(Rate) with an aggregation like MAX(Rate) or AVERAGE(Rate) ensures more consistent and reliable conditional formatting.

    If this solution works for you, please consider marking it as accepted so others facing a similar issue can benefit too!

    Let me know if you need help customizing the colors or logic further

    Regards,
    Akhil.