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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
HenryJS
Post Prodigy
Post Prodigy

Date Colour Coding Conditional Formatting

Hi all,

 

I would like to create a conditional formatting to the below 'Available' date column.

 

The conditions would be:

  • Green for 2 weeks in future
  • Amber for 2 weeks in past
  • Red for >2 weeks in the past

 

 

 

dax15.PNG

 

 

 

 

Thanks,

 

Henry

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @HenryJS 

create a calcualted column

Column = SWITCH(TRUE(),
DATEDIFF(TODAY(), [Available], WEEK) > -1 && DATEDIFF(TODAY(), [Available], WEEK) <=2, "Green",
DATEDIFF(TODAY(), [Available], WEEK) < 0 && DATEDIFF(TODAY(), [Available], WEEK) >= -2, "Amber",
DATEDIFF(TODAY(), [Available], WEEK) < -2, "Red",
BLANK()
)

then set this column as a field for conditional formatting in the visual settings

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


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

View solution in original post

2 REPLIES 2
az38
Community Champion
Community Champion

Hi @HenryJS 

create a calcualted column

Column = SWITCH(TRUE(),
DATEDIFF(TODAY(), [Available], WEEK) > -1 && DATEDIFF(TODAY(), [Available], WEEK) <=2, "Green",
DATEDIFF(TODAY(), [Available], WEEK) < 0 && DATEDIFF(TODAY(), [Available], WEEK) >= -2, "Amber",
DATEDIFF(TODAY(), [Available], WEEK) < -2, "Red",
BLANK()
)

then set this column as a field for conditional formatting in the visual settings

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


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

My powerbi didn't even recognize switch. This looked so promising but did not work for me

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.