SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


#Error when using =Iif statement


#Error when using =Iif statement

Author
Message
mmiller-537846
mmiller-537846
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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 Smile

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
Matt Miller (4)
Matt Miller (4)
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12209 Visits: 18574
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?
mmiller-537846
mmiller-537846
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 3
THANK YOU THANK YOU THANK YOU!!!!!!!!!!!!!BigGrin
sgfdgsdf
sgfdgsdf
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 163
Thanks, this is helpful.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search