Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JShea50
New Member

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"  Power BI Help.png 
1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

H, @JShea50 

Because your first measure did not consider the blank value.

If "Yes" then 1,else 0

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

vangzhengmsft_0-1638512026848.pngTry to modify your measure as follows

 

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

 

result:

vangzhengmsft_0-1638784974633.png

 

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.

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

H, @JShea50 

Because your first measure did not consider the blank value.

If "Yes" then 1,else 0

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

vangzhengmsft_0-1638512026848.pngTry to modify your measure as follows

 

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

 

result:

vangzhengmsft_0-1638784974633.png

 

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.

amitchandak
Super User
Super User

@JShea50 , 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")

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

 

Power BI Color.PNG

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.