Link to home
Start Free TrialLog in
Avatar of Mark01
Mark01Flag for United States of America

asked on

Incorrect Result from Formulas

I added five new formulas to a report (Daily_Dosage3b) and the results of the original three formulas on the new
report are different than on the original report (Daily_Dosage3a) that has only the original three formulas. Please
help me resolve the error. Why do the original formulas have a different result on the new report (Daily_Dosage3b)?

New formulas:
LowerTestResult = global numbervar LowerTestResult;
if {Test_Date.TestDate} = {?From Date} then
LowerTestResult := LowerTestResult + {Aspirin_Test.Reading};
LowerTestResult

UpperTestResult = global numbervar UpperTestResult;
if {Test_Date.TestDate} = {@ToDatePlusDay} then
UpperTestResult := UpperTestResult + {Aspirin_Test.Reading};
UpperTestResult

ToDatePlusDay = DateAdd (“D”,1,{?To Date})

TestResultDiff = {@UpperTestResult} - {@LowerTestResult}

Original formulas:
testAverageDosage = if not({@testDosageCount}=0) then {@testDosageAmount}/{@testDosageCount}
else 0

testDosageAmount = global numbervar dosageAmount;
if {Test_Date.TestDate} >={?From Date} and {Test_Date.TestDate} <= {?To Date} then
dosageAmount := dosageAmount + {Aspirin_Dosage.Dosage};
dosageAmount

testDosageCount = global numbervar dosageCount;
if {Test_Date.TestDate} >={?From Date} and {Test_Date.TestDate} <= {?To Date} then
dosageCount := dosageCount + 1;
dosageCount
User generated imageUser generated imageDaily_Dosage3a.rpt
Daily_Dosage3b.rpt
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark01

ASKER

No. Aspirin tests are not done every day. They can be performed once every 3 days,  5 days, 12 days, etc. Do I have to use a subreport in order to have a single report that has both aspirin dosing and test results?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark01

ASKER

I get an error when I change the join to the aspirin test table to LEFT OUTER. I will post a new question when I have more time to work on this report. Thank you, mlmcc.