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
Anonymous
Not applicable

Background Colour based on date

Hi

 

I have a list of Due Dates in a column 'AP Report (2)'[Due Date]

 

I need to colour these based on the following=

 

If date has passed or due in the next 7 days = red

Date 2 weeks to 1 month = Orange

Date > 1 month = Green 

 

Would anyone be able to advise me how to acheive this?

1 ACCEPTED SOLUTION
nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

Create a measure

 

Color =
VAR _due_date =
    SELECTEDVALUE ( 'AP Report (2)'[Due Date] )
VAR _days =
    DATEDIFF ( TODAY (), _due_date, DAY )
VAR _result =
    SWITCH ( TRUE (), _days < 7, "Red", _days < 30, "Orange", "Green" )
RETURN
    _result

 

Then use this measure in conditional formatting. (Format style by Field value).


Regards,
Nandu Krishna

View solution in original post

4 REPLIES 4
nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

Create a measure

 

Color =
VAR _due_date =
    SELECTEDVALUE ( 'AP Report (2)'[Due Date] )
VAR _days =
    DATEDIFF ( TODAY (), _due_date, DAY )
VAR _result =
    SWITCH ( TRUE (), _days < 7, "Red", _days < 30, "Orange", "Green" )
RETURN
    _result

 

Then use this measure in conditional formatting. (Format style by Field value).


Regards,
Nandu Krishna

Should that be _days in the switch statement instead of _due_date?

Anonymous
Not applicable


@kleigh wrote:

Should that be _days in the switch statement instead of _due_date?


That was it, fixed now 🙂 

Anonymous
Not applicable

This is giving me everything as a Green status

Jason_Auburn_0-1692023282224.png

 

16th August should be Red?

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.

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.