cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alan1
Regular Visitor

Calendar change color a month out and then when it is over due

Hello,

I have created an app to monitor when servicing is required for our fleet.

I would like each date category to change to orange when it is a month away from expiring and red if it has expired.

Can someone please help

Alan1_0-1643435804860.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Mister_Shaik
Solution Sage
Solution Sage

Hi @Alan1 ,

 

I'm assuming that you want to change the background color or fill, based on the date difference of today vs the due date. Then you can use this below expression in the background color or fill property,

 

If(DateDiff(Today(), DueDateControl.SelectedDate,Days) <= 0, Red, If(DateDiff(Today(), DueDateControl.SelectedDate,Days) < 30, Orange, RGBA(56, 96, 178, 1)))

 

You can change the "DueDateControl" to the date control name, whose date you want to compare with. 

 

What the above expression basically does is

  1. It'll first check if the date difference between due data and today is less than 0, if yes, it'll change color to Red
  2. If date difference is greater than 0 but less than 30, then it'll change it to Orange
  3. Else, it'll give the default blue background

 

Hope you find this helpful! 

 

Kind Regards,

Shaik Sha
________________________________________________________________________

If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Mister_Shaik
Solution Sage
Solution Sage

Hi @Alan1 ,

 

For the KMs left, you can use below expression for the fill property, (obviously you need to replace the KMSLeft with the data control name in your form)

If(Value(KMSLeft.Text) < 0, Red, If(Value(KMSLeft.Text) < 500, Orange, White))

It's basically checking the KMS left and setting it to Red if less than 0, else setting to Orange if less than 500 and if it's greater than 500 it's setting that to White.

 

For changing the format of your date control, you can simply do it using it's the "Format" property,
1. format.PNG

 

Hope this helps 🙂

 

Kind Regards,

Shaik Sha
________________________________________________________________________

If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Mister_Shaik
Solution Sage
Solution Sage

Hi @Alan1 ,

 

I'm assuming that you want to change the background color or fill, based on the date difference of today vs the due date. Then you can use this below expression in the background color or fill property,

 

If(DateDiff(Today(), DueDateControl.SelectedDate,Days) <= 0, Red, If(DateDiff(Today(), DueDateControl.SelectedDate,Days) < 30, Orange, RGBA(56, 96, 178, 1)))

 

You can change the "DueDateControl" to the date control name, whose date you want to compare with. 

 

What the above expression basically does is

  1. It'll first check if the date difference between due data and today is less than 0, if yes, it'll change color to Red
  2. If date difference is greater than 0 but less than 30, then it'll change it to Orange
  3. Else, it'll give the default blue background

 

Hope you find this helpful! 

 

Kind Regards,

Shaik Sha
________________________________________________________________________

If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Hello,

Can you please provide the code so that the fill for the KMs left field will automatically go orange for less than 500 and red when less than zero

Thanks


Alan

 

Alan1_0-1644716099662.png

 

Alan1
Regular Visitor

Sorry one more thing, how do i change the date so that it goes day/ month/ year and not Month/day/ year

 

Thanks in advance

Alan

 

Mister_Shaik
Solution Sage
Solution Sage

Hi @Alan1 ,

 

For the KMs left, you can use below expression for the fill property, (obviously you need to replace the KMSLeft with the data control name in your form)

If(Value(KMSLeft.Text) < 0, Red, If(Value(KMSLeft.Text) < 500, Orange, White))

It's basically checking the KMS left and setting it to Red if less than 0, else setting to Orange if less than 500 and if it's greater than 500 it's setting that to White.

 

For changing the format of your date control, you can simply do it using it's the "Format" property,
1. format.PNG

 

Hope this helps 🙂

 

Kind Regards,

Shaik Sha
________________________________________________________________________

If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,786)