Connecting Tech Pros Worldwide Help | Site Map

#Num!

Member
 
Join Date: Mar 2007
Posts: 46
#1: Mar 14 '08
One of my text fields in a report is:
=Sum([ConfAttendance])/Sum([ConfOffrate])

But how do I use the IIF statement on it to prevent the #NUM! error when dividing by zero?


Thanks!
Moderator
 
Join Date: Feb 2008
Location: Beauly, near Inverness, Scotland
Posts: 1,576
#2: Mar 14 '08

re: #Num!


Hi. Use of IIF to do this is
Expand|Select|Wrap|Line Numbers
  1. =IIF(Sum([ConfOffrate])=0, Null, Sum([ConfAttendance])/Sum([ConfOffrate]))
I have placed Null as the return value, as it would be inappropriate to return a value in such circumstances. Theoretically the result of division by zero is infinity. If you need to return a value for any reason change Null to 0, but understand that it is not representing the result of the division itself.

-Stewart
Reply