Kyra Slemp
Kyra Slemp

Reputation: 11

Background color based on two data dates

I am trying to color the background of the rows of the table in the report based on two dates. Here is the logic I am trying to get

Date A and Date B are both fields in my report.

Upvotes: 0

Views: 350

Answers (1)

Hannover Fist
Hannover Fist

Reputation: 10880

The SWITCH function will let you have multiple conditions with a results for each - like a CASE statement.

=SWITCH(Fields!DATE_A.Value <= DATEADD("d", 7, Fields!DATE_B.Value), "MintCream",
        Fields!DATE_A.Value >= DATEADD("d", 14, Fields!DATE_B.Value), "MistyRose",
        Fields!DATE_A.Value > DATEADD("d", 7, Fields!DATE_B.Value) AND Fields!DATE_A.Value < DATEADD("d", 14, Fields!DATE_B.Value), "Ivory",
        1 = 1, "LightGrey")

The first (and every other) argument is the expression to be evaluated, the second is the value if true.

A 1 = 1 can be added as an evaluated expression as an ELSE for the SWITCH.

I usually use paler shades for background highlighting.

Upvotes: 0

Related Questions