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!

Formula ??

Status
Not open for further replies.

pungigi

Programmer
Oct 29, 2003
115
US
I need to return the Average of 2 fields, how do I do that in a formula if Both fields = 0???

Crystal Advanced 9.0

Formula:
if Sum ({@Ambulance Miles}) >=0
then Sum ({@Ambulance Miles})/Sum ({@Ambulance Trips})
else 0

Ambulance Miles =0
Ambulance Trips =0

Would like to return 0 but not sure how.
 
Well if ambulance trips is zero then it's always going to cause problems:

Code:
if Sum ({@Ambulance Trips}) = 0 then 0 else
(if Sum ({@Ambulance Miles}) >=0
then Sum ({@Ambulance Miles})/Sum ({@Ambulance Trips})
else 0)

would work
 
try:

if Sum ({@Ambulance Trips}) = 0 then 0 else
(if Sum ({@Ambulance Miles}) >=0
then Sum ({@Ambulance Miles})/Sum ({@Ambulance Trips})
else 0)

does this work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top