Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Color Format in Matrix for Yes/No/Blank

I'm fairly new to Power BI and I am looking to change background colors in a Matrix based off the values being "Yes" "No" or blank.  

 

I created a mesure  Measure = IF(SELECTEDVALUE('Spreadsheet'[Caterer])="Yes",1,0)
I applied the rules for vaules only and that if value is 1 = green 0 = red and if vaule is blank = white
 
The problem is the blank vaules show as red too and not white.
 
I've also made sure the data in query editor is showing as "null"   
  • H, Anonymous 

    Because your first measure did not consider the blank value.

    If "Yes" then 1,else 0

    >>>("No",blank) >0, "Yes">1

    Try to modify your measure as follows

     

    Measure =
    SWITCH ( SELECTEDVALUE ( 'Spreadsheet'[Caterer] ), "Yes", 1, "No", 0, BLANK () )
    

     

    result:

     

    Best Regards,
    Community Support Team _ Zeon Zheng


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

3 Replies

  • Anonymous , It will not color blank value. Try a measure like this with the field value option 

     

    Measure = IF(coalesce(SELECTEDVALUE('Spreadsheet'[Caterer]),"No") ="Yes","Green","Red")

     

    or

     

    Measure = IF(coalesce(max('Spreadsheet'[Caterer]),"No") ="Yes","Green","Red")

    • Anonymous's avatar
      Anonymous
      Not applicable

      For both equations, the same issue occured where the blank values are being colored red

       

  • H, Anonymous 

    Because your first measure did not consider the blank value.

    If "Yes" then 1,else 0

    >>>("No",blank) >0, "Yes">1

    Try to modify your measure as follows

     

    Measure =
    SWITCH ( SELECTEDVALUE ( 'Spreadsheet'[Caterer] ), "Yes", 1, "No", 0, BLANK () )
    

     

    result:

     

    Best Regards,
    Community Support Team _ Zeon Zheng


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