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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jesfree13
New Member

Help With a conditional Formula based on Dates

I have a column in a table on my visual. with a date in it (some blanks). I need to color code the dates showing as follows

1. Dates 30  days out from todays date in Red (also some dates will be in the past)

2. Dates between 31 and 60 days in Yellow. 

3. Dates from 61+ in Green. 

 

Please help I have tried many things but just cannot get it to show correctly. I know it has something to do with the measure I am using. 

1 ACCEPTED SOLUTION
ray_aramburo
Super User
Super User

Try this:

Date Logic = 
var days = DATEDIFF(TODAY(), Table[DateColumn], DAY)
RETURN
IF(days >= 61, "Green", IF(days >= 31 && days < 61, "Yellow", "Red"))




Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
ray_aramburo
Super User
Super User

Try this:

Date Logic = 
var days = DATEDIFF(TODAY(), Table[DateColumn], DAY)
RETURN
IF(days >= 61, "Green", IF(days >= 31 && days < 61, "Yellow", "Red"))




Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





I am not sure where to enter that formula, Forgive my ignorance. 

No worries, that's why this forum exists 😀

Go to Home tab and find "New Measure"

ray_aramburo_0-1690309372639.png

 

In the Table[DateColumn] part just replace them with how they are named in your data. 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.