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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Reporting Services Development
 IIf statement not evaluating properly
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

71 Posts

Posted - 03/12/2014 :  10:42:34  Show Profile  Reply with Quote
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.

Yak Posting Veteran

71 Posts

Posted - 03/12/2014 :  10:50:08  Show Profile  Reply with Quote
Nevermind and sorry - found this and it works:
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 03/12/2014 :  10:50:19  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000