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

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

janetb
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.

janetb
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:

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

James K
Flowing Fount of Yak Knowledge

3585 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000