Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

summary

edited November 2005 in RAP
How can I create a summary that includes
variables and counts from each of the previously listed group footers?


--

Comments

  • edited November 2005

    ------------------------------------------------------
    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;



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2005
    Nard Moseley (Digital Metaphors) wrote:

    I understand this from the TIPS, My question is to create a summary
    where information from each group footer which contains the group name
    and totals items for the group is duplicated as a summary at the end of
    the report.
    Creating variable would require to know how many group footers there
    are before the report summary is created.







    --
  • edited November 2005


    One way to do this is to use SQL to create a summary query that contains the
    grouped calculations. Then use a subreport in the summary band. The
    subreport can traverse the summary query and generate the results.

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2005
    Nard Moseley (Digital Metaphors) wrote:


    I'm not sure I understand.
    I have already setup a query for the report. Could I setup a sub report
    in the summary band to re-traverse the data pulling out the totals I am
    looking for/ is there an example of this somewhere?

    --
  • edited November 2005

    You could do that also - connect the subreport to the same datapipeline.
    Each report/childreport will traverse the datapipeline to which it is
    assigned.

    I was originally thinking of creating a second SQL query that summarizes
    results by group. Then connect the subreport to the symmary query.

    example:

    Select CustNo,
    Sum(AmountPaid)
    From orders
    Group By CustNo







    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.