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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Conditional formatting based on datediff

Hi Experts

I have a dimdate table which starts at 01.01.2020 and increments everyday by 1 first column in dimdate table. I want to add a second column which allows me to apply the following CF rules
Based on today's date.
1. If date in row A dimdate table is >= 50 days then red
2. If <=15 days then green otherwise Amber.

Not sure is I need to add a second column to table and CF only works on numerical values.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous  , 

Create a measure to calculate the datediff and add Conditional formatting on the measure.

Here's the sample.

Measure = DATEDIFF(SELECTEDVALUE('Table'[date1]),SELECTEDVALUE('Table'[date2]),DAY)

1.PNG

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous  , 

Create a measure to calculate the datediff and add Conditional formatting on the measure.

Here's the sample.

Measure = DATEDIFF(SELECTEDVALUE('Table'[date1]),SELECTEDVALUE('Table'[date2]),DAY)

1.PNG

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

 

 

 

az38
Community Champion
Community Champion

Hi @Anonymous 

you can use conditional formatting using color name or HEX-code.

see examples here https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values and https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-based-on-a-calculation


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.