Divide by Zero Return Zero

A

Ava

=Avg(IIf([qryDRH_OBSbyMonthly]![dx_obs]<>"home",DateDiff
("h",([qryDRH_OBSbyMonthly]![obs_date]),
([qryDRH_OBSbyMonthly]![obs_disc]))))

This is my equation. It works for the most part but when
[dx_obs]<>"home" = 0 then it returns a null (divide by
zero) How can I make it return a zero if the equation
divides by zero??
 
R

Rick Brandt

Ava said:
=Avg(IIf([qryDRH_OBSbyMonthly]![dx_obs]<>"home",DateDiff
("h",([qryDRH_OBSbyMonthly]![obs_date]),
([qryDRH_OBSbyMonthly]![obs_disc]))))

This is my equation. It works for the most part but when
[dx_obs]<>"home" = 0 then it returns a null (divide by
zero) How can I make it return a zero if the equation
divides by zero??

I'm sorry, I see no division in this equation. Am I missing something?
 
A

Ava

This is a calulation based on a group in a report so it is
looking at a grouping and for all [dx_obs]<> home it is
taking the difference between 2 dates and then taking the
average of those differences. The problem is that when
[dx_obs]<> home = 0 the AVG function does not return
anything because there are zero records that fit the
criteria. I guess maybe I need to know either a better
way to write the equation or how I get the AVG function to
return a Zero even if there are no records that fit the
criteria.
-----Original Message-----
Ava said:
=Avg(IIf([qryDRH_OBSbyMonthly]![dx_obs]<>"home",DateDiff
("h",([qryDRH_OBSbyMonthly]![obs_date]),
([qryDRH_OBSbyMonthly]![obs_disc]))))

This is my equation. It works for the most part but when
[dx_obs]<>"home" = 0 then it returns a null (divide by
zero) How can I make it return a zero if the equation
divides by zero??

I'm sorry, I see no division in this equation. Am I missing something?


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top