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
Microsoft SQL ServerSSRSSQL

Avatar of undefined
Last Comment
joemccnz

8/22/2022 - Mon
Tim Humphries

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
ValentinoV

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck