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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dayna
Helper V
Helper V

Conditional formatting on a table based on an if statement

Hello,

 

I have a table on my report and I'd like to apply some conditional formatting.

 

I have a series of rows for product, etc and columns for 'Month / Year'. The value is 'Sum of Sales'. 

 

What I'd like to do is apply formatting on the value fields, where Month / Year is less than today's date, make the background colour yellow, otherwise, where it's today or greater, make green.

 

I can see there are rules that I can apply, but they seem to force expressions, where I just want a basic compare / if statement.

 

Can this be done? And if so, can you advise, please?

 

Many thanks,

Dayna

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Dayna , you can create a color measures and use that in conditional formatting using field value option

 

examples

 

Color Date = if(FIRSTNONBLANK('Date'[Date],TODAY()) <today(),"lightgreen","red")

 

Color Weekday = if(FIRSTNONBLANK('Date'[Weekday],blank()) in {"Sunday", "Saturday"},"lightgreen","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/...
Color Weekday = if(weekday(max('Date'[Date]),2) >=6 ,"lightgreen","red")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Dayna
Helper V
Helper V

Stunning solution, thank you!

amitchandak
Super User
Super User

@Dayna , you can create a color measures and use that in conditional formatting using field value option

 

examples

 

Color Date = if(FIRSTNONBLANK('Date'[Date],TODAY()) <today(),"lightgreen","red")

 

Color Weekday = if(FIRSTNONBLANK('Date'[Weekday],blank()) in {"Sunday", "Saturday"},"lightgreen","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/...
Color Weekday = if(weekday(max('Date'[Date]),2) >=6 ,"lightgreen","red")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.