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

Any ideas on totalling this report?

edited October 2003 in General
I have a report that has been built with one SQL that inner joins a parent
table with the detail table to produce the result set. The report utilizes
the group header to print a couple fields from the table and the detail band
prints the remainder of the fields. What is the best way to total the detail
items?


Customer Invoice Product Quantity Rate
Amount
ABC 001 <<< GROUP HEADER BAND
Belts 23
2.00 46.00 <<< DETAIL BAND
Hoses 5
6.00 30.00
Blades 18
9.00 162.00

Total 238.00 <<< GROUP FOOTER BAND

DEF 002
Belts 9
2.00 18.00
Hoses 2
6.00 12.00

Total 30.00

Here is where I need totals, something like the following

TOTALS Belts 32
64.00
Hoses 7
42.00
Blades 18
162.00

Total 268.00


Maybe the report was not designed correctly. Any ideas on how this can be
done is appreciated.

Thanks

Comments

  • edited October 2003
    Hi Stan,

    I assume you are using TppVariables in your the DetailBand to calculate the
    product of the item price multiplied by the quantity to get the item total.
    To calculate the grand totals I would place new TppVariables in your
    footer/summary band and update them using the origonal TppVariable's OnCalc
    events. Something like the following...

    procedure TForm.ppVariable1Calc(Sender: TObject; Value: Variant);
    begin
    {your existing code (similar)}
    Value := Report.DataPipeline['Rate'] * Report.DataPipeline['Quantity'];

    {new code for the totaling variable}
    ppTotalVar.Value := ppTotalVar.Value + Report.DataPipeline['Rate'] *
    Report.DataPipeline['Quantity'];

    end;

    You can then do something similar for the total quantity as well.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    I'm sorry for being a little lost in your reply. The totals also need to be
    summarized by product. Looking at the code you provided, I'm not sure how
    this is accomplished. What I'm missing something here.

    Thanks
    Stan


  • edited October 2003
    Stan,

    From your example, it appears that you are trying to create a summary by
    product after printing the details by customer. To produce the summary of
    products you can either create a subreport with another SQL query with the
    data summarized by product or you can process the result set from the first
    query into an array (and Sort the data) and use a JITPipeline to drive the
    array to produce the summary subreport. I've actually done the second
    method. I still have the proof of concept project that just uses the
    DBDEMOS database to create almost exactly what you have described. If you
    send me an e-mail I will send you the code for the sample project I created.

    Regards,
    Chuck Van Acker
    Alogent Corp.
    chuck.vanacker@alogent.com
  • edited October 2003
    Hi Chuck,

    Thanks for responding. I actually used an approach similar to your second
    method. Instead of using an array for the summary subreport, I used a
    TClientDataSet. The main reason for the original post was to see how other
    people were handling this same situation. Thanks again for the follow up.

    Stan


This discussion has been closed.