joemccnz
asked on
SSRS Conditional Formatting - Muliple conditions
I am setting up a conditional format for background colours in a report. See attachment for example of the report content.
I have created this expression under text box properties/fill...
=iif((Fields!time.Value < cdate(Today & " 08:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 08:10:00"), "red", "white")))
So, if time is before 8am colour is green, beween 8:00 and 8:10 colour is white, after 8:10 is red.
What I have above works however I only want to apply it to rows where the Load field is "first". For rows where Load is "Last" I want to use a similar conditional format to the above, but with time values for later on in the day.
Theoretically I want to have something like..
if load = "first" then do
=iif((Fields!time.Value < cdate(Today & " 08:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 08:10:00"), "red", "white")))
else
if load = "last" then do
=iif((Fields!time.Value < cdate(Today & " 15:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 15:10:00"), "red", "white")))
Is this possible in SSRS?
Capture.JPG
I have created this expression under text box properties/fill...
=iif((Fields!time.Value < cdate(Today & " 08:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 08:10:00"), "red", "white")))
So, if time is before 8am colour is green, beween 8:00 and 8:10 colour is white, after 8:10 is red.
What I have above works however I only want to apply it to rows where the Load field is "first". For rows where Load is "Last" I want to use a similar conditional format to the above, but with time values for later on in the day.
Theoretically I want to have something like..
if load = "first" then do
=iif((Fields!time.Value < cdate(Today & " 08:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 08:10:00"), "red", "white")))
else
if load = "last" then do
=iif((Fields!time.Value < cdate(Today & " 15:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 15:10:00"), "red", "white")))
Is this possible in SSRS?
Capture.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks ValentinoV, good article. Switch looks like the way to go.. however using the code you posted above everything is coloured white?
edit.. Just realized I needed to change the "First" and "Last" fields to start with capital letters, its working fine now, thanks
edit.. Just realized I needed to change the "First" and "Last" fields to start with capital letters, its working fine now, thanks
Should be something like:
=IIF(Fields!Load.Value = "first",
iif((Fields!time.Value < cdate(Today & " 08:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 08:10:00"), "red", "white")))
,
iif((Fields!time.Value < cdate(Today & " 15:00:00")), "Green", (iif(Fields!time.Value > cdate(Today & " 15:10:00"), "red", "white")))
)
i.s. just nesting your existing formulae.
Tim