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 checkmarks and x’s by the groupings. I do not need the groupings; I just couldn’t figure out how to do this.

  

The conditions for a green checkmark are by Credit Score:

  • A+ and A: >= 50%
  • B and C: 30%-40%
  • D, E AND No Score: <= 20%

The .pbix and spreadsheets for data are here: 

https://drive.google.com/drive/folders/1FgxlBg_464T2SBkGK5yF8slhwMaclTPU?usp=sharing

 

Thank you.

 

  • 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

7 Replies

    • jamoroso's avatar
      jamoroso
      Helper I

      Hi TomMartens ,

       

      Thanks for the reply, but unfortunately this does not solve my issue. My columns are actually one column broken into Groups, so I do not have 3 separate columns to apply the different formatting to. I am an occasional Power BI user and this is beyond my basic knowledge. Maybe I should not have broken it into Groups? I need 3 separate columns based on the values in the Loan Credit Score field and then need to format each column based on a different set of rules. 

      Thanks,

      Janet

      • TomMartens's avatar
        TomMartens
        Super User

        Hey jamoroso ,

         

        it was a good idea to group values using a "new" column in the same table, basically this is how dimensional modeling works.

         

        Consider uploading your pbix and the spreadsheets to one of the larger file shares like onedrive, googledrive, or dropbox and share the link. Make sure that we can download the files w/o to login.

         

        Regards,

        Tom

  • 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