#Error when using =Iif statement

  • 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

  • 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?

  • THANK YOU THANK YOU THANK YOU!!!!!!!!!!!!!:D

  • Thanks, this is helpful.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply