The easiest way to do this would be to keep track of these values using two TppVariables. See the article below for more information on making summary calculations inside a report.
------------------------------------------------------ Tech Tip: Calculating a Summary based on Group Totals ------------------------------------------------------
Question: I am using a Variable in the Group Footer to conditionally calculate totals for each group. I want to add a second Variable to the Summary that accumulates the results calculated for each group.
The following example uses two Variable components: vCustomerTotal and vCustomerSummary. The variable vCustomerTotal has its Timing defined to Reset on GroupEnd.
There are two options for accumulating the summary total.
1. Use the vCustomerTotal OnCalc event to accumulate the detail and the summary.
example:
procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant); begin
if (plCustomer['Amountpaid'] > 100.00) then begin {sum detail} Value := Value + plCustomer['Amountpaid'];
2. Set the timing of the Summary OnCalc to "GroupBeforeFooter" and accumulate the detail variable results. Note that here we use GroupBeforeFooter because the detail variable has its Reset defined as "GroupEnd" - implying that if we try to use GroupEnd for our summary calculation the accumulated results will be 0.
example:
procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant); begin
{sum detail} if plCustomer['Amountpaid'] > 100.00 then Value := Value + plCustomer['Amountpaid'];
end;
procedure vCustomerSummaryOnCalc(Sender: TObject; var Value: Variant); begin
{accumulate summary} Value := Value + vCustomerTotal.Value;
Comments
The easiest way to do this would be to keep track of these values using two
TppVariables. See the article below for more information on making summary
calculations inside a report.
------------------------------------------------------
Tech Tip: Calculating a Summary based on Group Totals
------------------------------------------------------
Question: I am using a Variable in the Group Footer to conditionally
calculate totals for each group. I want to add a second Variable to the
Summary that accumulates the results calculated for each group.
The following example uses two Variable components: vCustomerTotal and
vCustomerSummary. The variable vCustomerTotal has its Timing defined to
Reset on GroupEnd.
There are two options for accumulating the summary total.
1. Use the vCustomerTotal OnCalc event to accumulate the detail and the
summary.
example:
procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant);
begin
if (plCustomer['Amountpaid'] > 100.00) then
begin
{sum detail}
Value := Value + plCustomer['Amountpaid'];
{accumulate summary}
vCustomerSummary.Value := vCustomerSummary.Value +
plCustomer['Amountpaid'];
end;
end;
2. Set the timing of the Summary OnCalc to "GroupBeforeFooter" and
accumulate the detail variable results. Note that here we use
GroupBeforeFooter because the detail variable has its Reset defined as
"GroupEnd" - implying that if we try to use GroupEnd for our summary
calculation the accumulated results will be 0.
example:
procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant);
begin
{sum detail}
if plCustomer['Amountpaid'] > 100.00 then
Value := Value + plCustomer['Amountpaid'];
end;
procedure vCustomerSummaryOnCalc(Sender: TObject; var Value: Variant);
begin
{accumulate summary}
Value := Value + vCustomerTotal.Value;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com