Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 IIf statement not evaluating properly

Author  Topic 

janetb
Yak Posting Veteran

71 Posts

Posted - 2014-03-12 : 10:42:34
I have an IIF statement at a group level expression field that doesn't seem to be working correctly.

This test evaluates correctly to 0 on the group in question:
=iif( Sum(Fields!hours.Value)=0 or Sum(Fields!fees.Value)=0,0,1)

But when I replace it with what I need, I get an error:
=iif( Sum(Fields!hours.Value)=0 or Sum(Fields!fees.Value)=0,0,Sum(Fields!fees.Value)\Sum(Fields!hours.Value))

[rsRuntimeErrorInExpression] The Value expression for the textrun ‘grpChHr.Paragraphs[0].TextRuns[0]’ contains an error: Attempted to divide by zero.

Any help appreciated.

janetb
Yak Posting Veteran

71 Posts

Posted - 2014-03-12 : 10:50:08
Nevermind and sorry - found this and it works:

http://www.reportingservicestips.co.uk/RSTip008.html
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-03-12 : 10:50:19
SSRS scripts evaluate both cases of the IIF expression - that is why it is failing. (Also, I assume that the backslash in your posting is just a typo and is not in the actual code.) So you should do something to avoid evaluating that - for example like this:
sum(fields!fees.value)/iif(Sum(Fields!hours.Value)=0, Nothing,Sum(Fields!hours.Value))	
Not sure if that is the exact syntax, but something along those lines.
Go to Top of Page
   

- Advertisement -