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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.