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.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,538)