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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
park
Frequent Visitor

Conditional formatting by Date periods

Hi,

I would like to do conditional formatting on a table in PowerBI

where if the date is within the past 6 months it is green,

greater then 6 months it is yellow

and no date is orange.

 

Have tried everything and can't get it to work, thanks!

1 ACCEPTED SOLUTION
KNP
Super User
Super User

Hi,

 

It would be much easier if you posted some sample data.

Try creating a measure like this (you will need to change references to tables etc.)

Colour = 
var vToday = TODAY()
var vProcessDate = MIN('Table'[LAST_Process_DATE])
var result = 
SWITCH(
    TRUE(),
    ISBLANK( DATEDIFF(vProcessDate, vToday, MONTH)), "orange",
    DATEDIFF(vProcessDate, vToday, MONTH) > 6, "yellow",
    DATEDIFF(vProcessDate, vToday, MONTH) < 6, "green"
    )
RETURN
result

 

Assign this to the formatting by field.

KNP_0-1659297652979.png

 

KNP_1-1659297692898.png

 

 

 

See attached PBIX.

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

2 REPLIES 2
KNP
Super User
Super User

Hi,

 

It would be much easier if you posted some sample data.

Try creating a measure like this (you will need to change references to tables etc.)

Colour = 
var vToday = TODAY()
var vProcessDate = MIN('Table'[LAST_Process_DATE])
var result = 
SWITCH(
    TRUE(),
    ISBLANK( DATEDIFF(vProcessDate, vToday, MONTH)), "orange",
    DATEDIFF(vProcessDate, vToday, MONTH) > 6, "yellow",
    DATEDIFF(vProcessDate, vToday, MONTH) < 6, "green"
    )
RETURN
result

 

Assign this to the formatting by field.

KNP_0-1659297652979.png

 

KNP_1-1659297692898.png

 

 

 

See attached PBIX.

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
park
Frequent Visitor

I have a table with LAST_Process_DATE as the dates

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors