cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimboSey
Helper V
Helper V

Change colour based on date being 7 days or less before deadline

Hi,

 

I have a gallery in my App, linked to a SP list. Within that list there are three columns, ‘HL_PRojectStartDate’, HL_Deadline and HL_PRojectCompleteDate.

 

I have the following code in the Color property of an icon within the gallery, so that the icon changes red if the status of the project is live but the deadline has passed.

 

If(Today() > ThisItem.HL_Deadline And ThisItem.HLStatus.Value = "Live",

   Color.LightCoral, LightGray)

 

I now want to add coding to this, whereby the icon changes yellow if the HL_Deadline is 7 days or less than Today and the status column is showing Live

 

 

Any help much appreciated, thank you

9 REPLIES 9
Nogueira1306
Super User
Super User

If(DateDiffThisItem.Date Today() , Days) <= 7, YELLOW, RED)

 

https://docs.microsoft.com/EN-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

Thanks @Nogueira1306 

 

This didnt seem to work when added to the code I provided in my original post, sadly.

The item can have 4 colors??

Just three

If(Today() > ThisItem.HL_Deadline And ThisItem.HLStatus.Value = "Live",

   Color.LightCoral,

   If(DateDiffThisItem.Date Today() , Days) <= 7, YELLOW, RED)

)

 

Maybe that???

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

Sadly not.

 

If this helps...

 

My gallery has three labels which pull the dates from date columns in my SP list.

 

I have an icon next to the label, and want the icon to change based on the date in the label, so it turns yellow when todays date is within 7 days or less from the date in the label, and change red when todays date exceeds the date in the label.

 

Thanks

Hi @JimboSey ,

There are many more possibilities from what you have posted and you will need to see if the below addresses them, but you will get the idea

If(
   ThisItem.HLStatus.Value = "Live",
   With(
      {
         wDays:
         DateDiff(
            ThisItem.HL_Deadline,
            Today(),
            Days
         )
      },
      If(
         wDays >= 0 And wDays =< 7,
         Yellow,
         wDays < 0,
         Red,
         Today() > ThisItem.HL_Deadline,
         LightCoral, 
         LightGray
      )
   ),
   LightGray
)

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

WarrenBelz
Super User
Super User

Hi @JimboSey ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

@WarrenBelz I figuered out a different code which worked for what I needed but thank you for your help. 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,558)