drcoding
drcoding

Reputation: 173

Nested If Statements SSRS Expression

Building a report and changing colour based on some variables. If it is a Break Semester then make the colour "Gainsboro". If attendance is less than 0.4 as well as not being null then make the colour "#ffc7ce"

I'm totally confused as to why this code won't run, it seems simple enough.

=IIF(fields!Break_Semester <> "Break Semester"
    ,IIF(len(Fields!Attendance.Value) <> 0 and Fields!Attendance.Value < 0.4 
        ,"#ffc7ce"
    ,"Gainsboro")
,"Gainsboro")

The code works when running this:

=IIF(len(Fields!Attendance.Value) <> 0 and Fields!Attendance.Value < 0.4 
    ,"#ffc7ce"
,"Gainsboro")

So I'm not sure why the nesting screws it up.

Any pointers?

Upvotes: 2

Views: 254

Answers (1)

Steve-o169
Steve-o169

Reputation: 2146

I believe you've simply misidentified the Break_Semester field. Make sure to capitalize the Fields portion and you need to add .Value. So it should be

=IIF(Fields!Break_Semester.Value <> "Break Semester"
,IIF(len(Fields!Attendance.Value) <> 0 and Fields!Attendance.Value < 0.4 
    ,"#ffc7ce"
    ,"Gainsboro")
,"Gainsboro")

Could be nice to add parenthesis around your conditional statements as well, but that's just a personal preference to keep things cleaner.

Upvotes: 2

Related Questions