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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join 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-calc...


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

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.