cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bsamms
Frequent Visitor

Change color of text displayed in gallery based on dates - overdue

In a gallery, I have a "status" field displayed, which changes it's value based on case progression.  I have been asked to have the text color of that item change based on date fields:  "DateAssigned" and "DateDue", which are typically about two weeks apart.  I've not been successful with trying to modify other date specific 'if' commands to change the color, and any help would be appreciated.

 

Ideally, the color would start green and remain that color for 7 days, then turn yellow for the next 7 days, then red after the due date.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @bsamms ,

Could you please share a bit more about your scenario?

Are there two weeks difference between the "DateAssigned" field and "DateDue" field?

Further, do you want to change the Color of the "Status" Label Text based on the "DateAssigned" field and "DateDue" field?

 

I have made a test on my side, please consider take a try with the following workaround:

I assume that there are two weeks difference between the "DateAssigned" field and "DateDue" field. Please set the Color property of the "Status" Label inside the Gallery to following:

If(
   DateDiff(ThisItem.DateAssigned, Today()) <= 7,
   Color.Green,
   DateDiff(ThisItem.DateAssigned, Today()) > 7 && DateDiff(ThisItem.DateAssigned, Today()) <= 14,
   Color.Yellow,
   DateDiff(ThisItem.DateAssigned, Today()) > 14,
   Color.Red
)

Note: It is not necessary to compare with the "DateDue" field value in above formula.

 

You could also consider try the following formula:

If(
   Today() <= DateAdd(ThisItem.DateDue, -7),
   Color.Green,
   Today() > DateAdd(ThisItem.DateDue, -7) && Today() < ThisItem.DateDue,
   Color.Yellow,
   Today() > ThisItem.DateDue,
   Color.Red
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
dariobois
Resolver II
Resolver II

Hi @bsamms 

You can use an IF Condition to do that.

 

try this,

 

LabelSTATUS -> Color

If(ThisItem.Status = "some value", RGBA(0; 255; 0; 1), RGBA(255; 0; 0; 1))

 

Regards!

dariobois
Resolver II
Resolver II

 


@bsamms wrote:

In a gallery, I have a "status" field displayed, which changes it's value based on case progression.  I have been asked to have the text color of that item change based on date fields:  "DateAssigned" and "DateDue", which are typically about two weeks apart.  I've not been successful with trying to modify other date specific 'if' commands to change the color, and any help would be appreciated.

 

Ideally, the color would start green and remain that color for 7 days, then turn yellow for the next 7 days, then red after the due date.


Sorry, i didn't see that.

 

try this

 

LabelSTATUS -> Color

If(DateDiff(ThisItem.DateField,Today()) < 7, RGBA(0, 255, 0, 1), If(DateDiff(ThisItem.DateField,Today()) > 7, RGBA(255, 255; 0, 1)))

v-xida-msft
Community Support
Community Support

Hi @bsamms ,

Could you please share a bit more about your scenario?

Are there two weeks difference between the "DateAssigned" field and "DateDue" field?

Further, do you want to change the Color of the "Status" Label Text based on the "DateAssigned" field and "DateDue" field?

 

I have made a test on my side, please consider take a try with the following workaround:

I assume that there are two weeks difference between the "DateAssigned" field and "DateDue" field. Please set the Color property of the "Status" Label inside the Gallery to following:

If(
   DateDiff(ThisItem.DateAssigned, Today()) <= 7,
   Color.Green,
   DateDiff(ThisItem.DateAssigned, Today()) > 7 && DateDiff(ThisItem.DateAssigned, Today()) <= 14,
   Color.Yellow,
   DateDiff(ThisItem.DateAssigned, Today()) > 14,
   Color.Red
)

Note: It is not necessary to compare with the "DateDue" field value in above formula.

 

You could also consider try the following formula:

If(
   Today() <= DateAdd(ThisItem.DateDue, -7),
   Color.Green,
   Today() > DateAdd(ThisItem.DateDue, -7) && Today() < ThisItem.DateDue,
   Color.Yellow,
   Today() > ThisItem.DateDue,
   Color.Red
)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,145)