With(
{
localDeadline:
If(
IsBlankOrError(ThisItem.'Deadline'),
Blank(),
DateAdd(
DateTimeValue(ThisItem.'Deadline'),
TimeZoneOffset(DateTimeValue(ThisItem.'Deadline')),
TimeUnit.Minutes
)
),
now: Now(),
// Excel table column is text; make comparison robust to case/spaces
reqStatus: Lower(Trim(Coalesce(ThisItem.'Request Status', "")))
},
If(
IsBlank(localDeadline),
CustomTheme.PrimaryColor, // no deadline → theme color
If(
localDeadline > DateAdd(now, 2, TimeUnit.Days), // > 2 days out
RGBA(59, 151, 110, 1), // green
If(
localDeadline >= now And reqStatus = "completed",
RGBA(59, 151, 110, 1), // due within 2 days AND Completed → green
If(
localDeadline >= now,
RGBA(251, 188, 5, 1), // due within 2 days → amber
RGBA(234, 67, 53, 1) // overdue → red
)
)
)
)
)
I put this formula in the "Color" property of a text label. It is supposed to
- change the color of the text to green if Deadline is more than two days from today,
- leave the color as CustomTheme.PrimaryColor if Deadline is blank or has an error,
- change text to green when Deadline is today or overdue but if Request Status is "Completed",
- change text to amber if Deadline is within two days from today, and
- change text to red if Deadline is today or overdue.
The formula is only changing the text to CustomTheme.PrimaryColor & then red. Why is it not doing the other conditions?