ItalianStallion4215
ItalianStallion4215

Reputation: 138

SSRS background color expression based by date value

Here is my issue, I have a table in SSRS that I've created that has a due date field (RegulatoryDateDecisionDue). Based on that date field, I need to change the colors of the rows if today's date is past the due date the field should be red. If the amount of hours are less than or equal to 72 hours from today's date till the due date (basically like a countdown till it's due), the rows should be orange, else rows should be white.

Here is the expression I wrote, but I am having an issue, I get error, and idea what I am doing wrong or if I should be doing this differently? Any and all help appreciated.

=IIF((now() > Fields!RegulatoryDateDecisionDue.Value), "Red", IIF(((DateDiff(DateInterval.Hour, Fields!RegulatoryDateDecisionDue.Value, Now()) <= "72"), "Orange", "White")))

Upvotes: 0

Views: 3313

Answers (2)

alejandro zuleta
alejandro zuleta

Reputation: 14108

Try:

=Switch(
DateDiff(DateInterval.Hour, Fields!RegulatoryDateDecisionDue.Value, Now())<=72,"Orange",
Fields!RegulatoryDateDecisionDue.Value<now(),"Red",
true,"White"
)

It is better use Switch for multiple conditions.

Let me know if this helps.

Upvotes: 1

NdsAerith
NdsAerith

Reputation: 86

Some things to try :

  • Use a switch instead of iif to have a better reading
  • use "h" insted of DateInterval.Hour
  • write 72 instead of "72"

Upvotes: 0

Related Questions