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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Conditional formatting font color and cell background color in matrix visual

Hi guys,

I'm trying to solve this issue, where

I have 9 columns [1-date and 8 - value cols] where i want to do conditional formatting for FONT and BACKGROUND.

FONT COLOR

COL[1-3] : if the cell have value 1 format 'green' else red. 

COL[4-8] : Some cols should have value 96 & some 144 . Same green and red

Background Color

COL[1-3] : If it is 'SUNDAY','MONDAY','TUESDAY' cell color should be say 'orange' but if it is other day and missing value give  'red'

col[1-4] : NO Sunday,monday if there is missing value give cell color red.

 

I was able to give font color as red and green through Switch statement. I am not able to pull out the background color. is there any method i can code a measure to give the background colors. I am not able to put [day_of_the_week] column beside date in matrix as row o.w i guess it would have been possible. but there is a column for day in the table.

Thanks and please help.

Attached a image acc to bg color. Sorry for the bad edits. bic.png

5 REPLIES 5
magjag
New Member

Hi,

to change only specific rows backgroud color try below DAX measure,

and use it with Conditional Formating.

(Conditional Formating-> Backgroud color-> Field value)

 
Color Weekend = SWITCH(true(),MAX('Calendar[DayName]) IN {"Saturday","Sunday"},"#F7CE8E","#FFFFFF00"),
 
where #F7CE8E is orange color code
where #FFFFFF00 is no color (transparent)
 
Magda
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Can you share a simple file to remove sensitive information, and show the results you want to output, sometimes the blank can not be colored, because the matrix is converted to table you can find that there may not be a cell at all.


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hii @v-yalanwu-msft , thanks for the reply. Yes, no matter how much i try i can't fill in the blank cells. I'm sharing a screenshot of the table and requirements as somehow i'mnot able to share a PBI file. Please read through and if you have a solution please share it'll be a great help

Thankyou!!.dummy_ss.png

amitchandak
Super User
Super User

@Anonymous , You can create a color measure and use that in conditional formatting using field value option

 

example

Color Weekday = if(FIRSTNONBLANK('Date'[Weekday],blank()) in {"Sunday", "Saturday"},"lightgreen","red")


Color Weekday = if(weekday(max('Date'[Date]),2) >=6 ,"lightgreen","red")

 

Switch(true(),
[SLA] = 1 , "Green" ,
[SLA] >= .5 , "Amber" ,
"Red "
)
)

 

Color Date =
var _min =minx(allselected(Date,Date[Year])
return
Switch( true(),
FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"lightgreen",
FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"blue",
"red")

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/1682539

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

I'm trying to insert the COLOR_WEEKDAY measure as you said but it doesn't consider's the blank columns that the table has, it also happens trying different methods like if or switch to give bg color

ShubhamPandey_0-1656041235163.png

Color Weekday = if(FIRSTNONBLANK('Date'[Weekday],blank()) in {"Sunday", "Saturday"},"lightgreen","red")

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

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