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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
kmlcoch
Frequent Visitor

Conditional Formatting

I have a date column that I am showing in a table. The column is an expiration date and I want to format it so that the date will turn red if the expiration date is within the next 30 days. Is there a way to do that?

 

Thank you!

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@kmlcoch you can use conditional formatting and use field value and in field value use following measure:

 

Color Measure = 
VAR __days = DATEDIFF ( TODAY (), MAX( Table[Date] ), DAY )
RETURN
IF ( __days > 90, "Red" )

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

speedramps
Super User
Super User

Try this DAX measure ....

 

RAG =
// get the number of days remaining
// if the value is between 0 and 30 the return red
VAR daysremaining = DATEDIFF(   TODAY()  ,SELECTEDVALUE(yourtablename[ExpiryDate]),  DAY )  
RETURN
IF( daysremaining >=0  && daysremaining <=30, "Red")

 

 

The create a table visual with your date.

Click consitional fomating / Font colour /

Format style = Field value  / Based on field = RAG

 

see screen print below

 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remeber we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

 

speedramps_0-1662501359258.png

 

 

View solution in original post

2 REPLIES 2
speedramps
Super User
Super User

Try this DAX measure ....

 

RAG =
// get the number of days remaining
// if the value is between 0 and 30 the return red
VAR daysremaining = DATEDIFF(   TODAY()  ,SELECTEDVALUE(yourtablename[ExpiryDate]),  DAY )  
RETURN
IF( daysremaining >=0  && daysremaining <=30, "Red")

 

 

The create a table visual with your date.

Click consitional fomating / Font colour /

Format style = Field value  / Based on field = RAG

 

see screen print below

 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remeber we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

 

speedramps_0-1662501359258.png

 

 

parry2k
Super User
Super User

@kmlcoch you can use conditional formatting and use field value and in field value use following measure:

 

Color Measure = 
VAR __days = DATEDIFF ( TODAY (), MAX( Table[Date] ), DAY )
RETURN
IF ( __days > 90, "Red" )

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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