Forum Discussion

YunJ's avatar
YunJ
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

How to set background color?

hi,

I met two problems when I use background color.

First, when I use "Format by Field value", it errors and says don't recognize.

Second, I want to set the color for rows of matrix for which Sales2 is not blank. But the only way I can do this is set for each measure right? For example, when I set Sales background color, I cannot find "is not blank". 

I also think it's tricky to set for each measure. I want the whole row to be colored only if Sales2 is not blank.

Here is the pbix file: 

https://www.dropbox.com/s/5s5drfgix1xhsut/conditional%20color.pbix?dl=0

Thanks a lot!

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi YunJ ,

     

    Create a measure and set it in Conditional formatting.

    Measure = IF(MAX('Number'[Sales2])<>BLANK(),"light blue")

     

     

     

    You can check more details from here.

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • YunJ , to use the field value option. You need to return color. Create a measure that return color name or hexcode

    example

    Colour = 
    SWITCH(TRUE(),
    'Table'[Date] < TODAY(), "red",
    'Table'[Date] = TODAY(), "orange",
    "green")
    
    Colour = 
    SWITCH(TRUE(),
    max('Table'[Month Year]) = "Jan-2020", "red",
    Max('Table'[Month Year]) < "Feb-2020", "orange",
    //keep on adding
    "green")
    
    Measure =
    Switch(true(),
    max(Table[Column]) = "R1" , "Red" ,
    max(Table[Column]) = "R2" , "Green" ,
    max(Table[Column]) = "R3" , "Pink " 
    )

    Check

    https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
    https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

    • YunJ's avatar
      YunJ
      Icon for Post Prodigy rankPost Prodigy

      Hi amitchandak Thanks for sharing. Do you have any thought on the second question? I want to set color for rows where Sales2 is not blank.

       

      Thanks a lot for your time!

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi YunJ ,

         

        Create a measure and set it in Conditional formatting.

        Measure = IF(MAX('Number'[Sales2])<>BLANK(),"light blue")

         

         

         

        You can check more details from here.

         

         

         

        Best Regards,

        Stephen Tao

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi YunJ ,

    Could you tell me if your problem has been solved?
    If it is, kindly Accept it as the solution. More people will benefit from it.
    Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.


    Best Regards,
    Stephen Tao