Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

#Error when using =Iif statement Expand / Collapse
Author
Message
Posted Thursday, November 1, 2007 3:35 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 20, 2008 1:07 PM
Points: 2, Visits: 3
I am trying to do basic Reporting Services, because that is all that I know....so if the answer has to do with code and such, please be specific as to what I need because I have not learned that yet :)

I am doing the following

=iif(sum(Fields!Deqsum.Value) = 0,0,(SUM(Fields!Deqsum.Value)/SUM(Fields!Totsum.Value)))

I am getting an #Error when the DeqSum = 0.00 and the Totsum = 0.00

I have validated that there are NO nulls in my tables, just zeros. How do I work around this so it gives me a 0% instead of #Error?

Thanks so much for any help!
Marissa
Post #417666
Posted Thursday, November 1, 2007 3:52 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:13 PM
Points: 7,156, Visits: 15,255
You have to prevent totsum from being 0, since that is what is causing your divide by zero #ERROR's.

If you want that to evaluate to 0 then try:
=iif(sum(Fields!Deqsum.Value) = 0,0,
(SUM(Fields!Deqsum.Value) *iif(SUM(Fields!Totsum.Value)=0,0,1)
/
iif(SUM(Fields!Totsum.Value)=0,1,SUM(Fields!Totsum.Value))))


----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #417671
Posted Thursday, November 1, 2007 3:59 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 20, 2008 1:07 PM
Points: 2, Visits: 3
THANK YOU THANK YOU THANK YOU!!!!!!!!!!!!!:D
Post #417673
Posted Wednesday, June 25, 2014 8:30 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, September 14, 2014 10:10 PM
Points: 3, Visits: 150
Thanks, this is helpful.
Post #1586210
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse