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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having trouble w/ simple division formula

Status
Not open for further replies.

andie18

MIS
Aug 14, 2001
198
US
alrighty - what the hey am I doing wrong here?

CR 8.5 developer / GoldMine 5.5 SQL 2K

My report has 1 group - conthist.userid.

Then I have a handful of formulas. I'll give am example of my problem:

Formula #1 counts # calls made within a date range:

if {conthist.rectype} startswith "C" then 1 else 0 - wrks fine

Formula #2 counts # hits from the calls:

if{conthist.resultcode} = "HIT" then 1 else 0 - works fine

Formula #3 is suppose to take the sums of each formula and divide them. I have tried the real simple and ended up with this (which is still fairly simple) and it still does the same thing:

whileprintingrecords;
numbervar hits;
numbervar calls;

hits := sum({@call hit});
calls := sum ({@Calls});

(calls / hits)

I get the same number for each user. What did I screw this up?

btw... thank in advance for any help - I appreciate it!
 
I figured out some of my problem. I had to change my formula for the division:

(Sum ({@Calls}, {CONTHIST.USERID}) / sum ({@call hit}, {CONTHIST.USERID}))

works just fine with the exception of if one of the values is 0 so I added this line to my formula:


If sum({@call hit})=0 then totext ("0") else totext

When I run the report, I get an error "division by zero" I checked my properties and I have the NULL checkboxes checked so what gives?
 
I have also tried:

If (Sum({@Calls}, {CONTHIST.USERID}) / sum ({@call hit}, {CONTHIST.USERID})) = 0
then 0 else
(Sum ({@Calls}, {CONTHIST.USERID}) / sum ({@call hit}, {CONTHIST.USERID}))

no dice. How frustrating
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top