Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with field = 0 yields #Num!

Status
Not open for further replies.

PleaseGiveHelp

Programmer
Oct 29, 2002
131
US
Ok so I know I've done this before and so I don't know why it isn't working. I have a field on my report which ends up being 0. I know you can't divide by 0 so I'm trying to come up with a switch statement to take care of that and to yield 1. This is what I have:

=Switch([AllCounts]=0,1,[AllCounts]<>0,([YesCounts]/[AllCounts]))

Yet the report yields #Num!. Is my switch statement wrong? Do I need to account for the top number being 0 as well?
 
I don't see anything wrong with the Switch statement, so perhaps the issue is a Null for one of the fields. Also, in this case, I don't a Switch statement is best. I would try using an IIF statement

=IIf((Nz([AllCounts],0)=0),1,(Nz([YesCount],0)/Nz([AllCounts],1)))


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top