Adding 2 averages
I want to add the averages from 2 columns but the result I get is the sum of
the totals of the 2 columns. I am using dbCalc on the 2 fields and they
show up correctly on the report. It's just the variable that adds them that
is wrong.
procedure TfrmTrending.ppVarTotAvgCalc(Sender: TObject;
var Value: Variant);
begin
Value := ppDBCalcMinAvg.Value + ppDBCalcMinTAvg.Value;
end;
Delphi 5 Pro, RB 6.03.
--
Don Gollahon
gollahon@geneseo.net
the totals of the 2 columns. I am using dbCalc on the 2 fields and they
show up correctly on the report. It's just the variable that adds them that
is wrong.
procedure TfrmTrending.ppVarTotAvgCalc(Sender: TObject;
var Value: Variant);
begin
Value := ppDBCalcMinAvg.Value + ppDBCalcMinTAvg.Value;
end;
Delphi 5 Pro, RB 6.03.
--
Don Gollahon
gollahon@geneseo.net
This discussion has been closed.
Comments
When the DBCalc component is accumulating values to calculate an average, it
stores the sum of the records in the Value property and the count of the
records in the Divisor property. Then in the OnGetText event, it calculates
the average using these two numbers. If you would like to add the two
averages you can try converting the DBCalc.Text value to a Float or make the
average calcluation on your own like the example below.
Value := (ppDBCalcMinAvg.Value / ppDBCalcMinAvg.Divisor) +
(ppDBCalcMinTAvg.Value / ppDBCalcMinTAvg.Divisor);
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com