Link to home
Start Free TrialLog in
Avatar of joemccnz
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
Avatar of Tim Humphries
Tim Humphries
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi,

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
ASKER CERTIFIED SOLUTION
Avatar of ValentinoV
ValentinoV
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joemccnz
joemccnz

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