Forum Discussion

savulesc's avatar
savulesc
Icon for Helper I rankHelper I
4 years ago
Solved

Conditional formatting just for some cells in a matrix

I have a matrix with this structure:

NAME      Program    Actual

Kpi1R166.5
Kpi1R243.5
Kpi1R370.9
Kpi2R12
Kpi3R22
Kpi4R33

 

Name and Program are columns, Actual is a measure.

How can I use conditional formatting for the Actual field only for the first 3 cells (when NAME = Kpi1)?, so, if ACTUAL > 80% -> green , <75 -> red, between 75-80 no color.

  • Add a measure to set the formatting color and check for the KPI1 row like this.

    Format Color = 
    SWITCH ( 
        TRUE(),
        SELECTEDVALUE ( YourTable[Name] ) = "KPI1",
        SWITCH(
            TRUE,
            [Actual] <= 75, "Red",
            [Actual] >= 80, "Green"
        )
    )

    Then apply that measure as the background color to the value:

9 Replies

  • Add a measure to set the formatting color and check for the KPI1 row like this.

    Format Color = 
    SWITCH ( 
        TRUE(),
        SELECTEDVALUE ( YourTable[Name] ) = "KPI1",
        SWITCH(
            TRUE,
            [Actual] <= 75, "Red",
            [Actual] >= 80, "Green"
        )
    )

    Then apply that measure as the background color to the value:

    • savulesc's avatar
      savulesc
      Icon for Helper I rankHelper I

      This is not working for me, all the rows are green even if they should not.

      • jdbuchanan71's avatar
        jdbuchanan71
        Icon for Super User rankSuper User

        If your [Actual] measure is a % then you would apply it at .75 and .8 like this.

        Format Color = 
        SWITCH ( 
            TRUE(),
            SELECTEDVALUE ( YourTable[Name] ) = "KPI1",
            SWITCH(
                TRUE,
                [Actual] <= .75, "Red",
                [Actual] >= .80, "Green"
            )
        )
  • savulesc you cannot use conditional formatting on a column used in the rows but if you are using table visual, you can apply conditional formatting on the column on a row. Add a new measure for conditional formatting and then use table visual and apply field value for Name column using the color measure

     

    Color KPI = 
    VAR __actual = [Actual Measure]
    RETURN
    SWITCH ( TRUE(),
       __actual > .80, "Green",
       __actual < .75, "Red"
    )

     

     

    ✨ Follow us on LinkedIn and  to our YouTube channel

    I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    ⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

     

    • savulesc's avatar
      savulesc
      Icon for Helper I rankHelper I

      I didn't really understand your response, but I don't want to use conditional formatting on the Name column , because that doesn't help me at all.

  • jdbuchanan71 Thanks for correcting. I missed the KPI name condition but you cannot apply conditional format on a column on the row in the matrix visual, visual still need to be changed to table visual

     

     

    ✨ Follow us on LinkedIn and  to our YouTube channel

    I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    ⚡ Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

     

  • Can you post your .pbix file (load it to drop box and share the link)?  My formula works in my test.

    • savulesc's avatar
      savulesc
      Icon for Helper I rankHelper I

      I found the issue. For some reason i had to put <= "65%" in the measure. Thanks for your help.