Forum Discussion

jamoroso's avatar
jamoroso
Helper I
3 years ago
Solved

Adding conditional formatting to a matrix.

Hello, I am trying to add the green checkmarks and red x’s like below to my Power BI matrix. I grouped the Loan Credit Score column into the 3 groups, but cannot figure out how to assign the checkma...
  • TomMartens's avatar
    3 years ago

    Hey jamoroso ,

     

    this measure is almost creating what you are looking for:

     

    vizAid Icon = 
    var currentValue = [Originations]
    var currentColumnContext = SELECTEDVALUE( 'Loans'[LoanCreditScore (groups)] )
    var greencheckmark = "CircleSymbolHigh"
    var redCircle = "CircleSymbolLow"
    return
    SWITCH( currentColumnContext
        , "A+ & A"
            , var upperbound = 0.5
            return
            IF( currentValue >= upperbound
                , greencheckmark
                , redCircle
            )
        , "B & C"
            , var upperbound = 0.4
            var lowerbound = 0.3
            return
            IF( currentValue >= lowerbound && currentValue <= upperbound
                , greencheckmark
                , redCircle
            )
        , "D & E & No Score"
            , var upperbound = 0.2
            return
            IF( currentValue <= upperbound
                , greencheckmark
                , redCircle
            )
    )

     

    Here is the matrix visual after I added the measure to the Cell elements for the Icon formatting:

    You have to adjust the lowerbound and upperbound values though.

     

    This approach is based on a measure that returns an icon. I'm using two of the default icocns, if you want to use exactly the icons from your example, then you have to add the icons.

    Here you will find an explanation of how to create measures that return icons: https://radacad.com/power-bi-icon-names-for-conditional-formatting-using-dax
    And this video explains how to add custom icons/KPIs based on svg images: https://www.youtube.com/watch?v=z7eyZM2b4Z8

     

    Hopefully, this helps what you are looking for.

     

    Regards,

    Tom