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

RE-Calculating Totals

edited July 2006 in General
RB10 Server / Delphi6 Environment / Oracle

I've got a set of "simple" columnar reports that have both line totals and
column totals. Everything rounds correctly and totals great by summing up
the transactions. (This is total "a")

To accomodate the age old problem of the parts don't always equal the
whole - I now need to RE-Calculate the line and column totals before they
are printed so they round differently. (This is Total "b")

In a past life I used a temporary table to add up the amounts and them
re-calculate the total before printing it. Is there a way to do this in RB?
I've tried the hidden variable route with limited success. The numbers
variables an complexity of the report become overwhelming. Is there just a
way to say in the OnPrint to recalc the total?


So this one summary line is really 25+ detail transactions. Summed up the
detail and summary reports are total "A". I need to produce hrs*rate for
Total "B"

Name Hours Rate Total(a) Total(b)
------ ------- -------- --------- --------
ABC 80 10.2345 818.75 818.76

Comments

  • edited July 2006
    Hi John,

    How are you initially calculating Total A? If you are perhaps using the
    OnCalc of a TppVariable component, you could simply make two calculations
    inside that event, rounding one differently. Another option would be to
    calculate the total manually (by traversing the dataset yourself and storing
    the total you need), then manipulating this value when you need it in the
    summary band.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2006
    Nico - Total "A" is just a summary total via a dbCalc field set to sum and
    print the total in a group footer. So RB is doing all of the calculations
    internally. Is it possible to override the total calculated and print
    Total "B" by doing a calculation and stuffing a value?

    So I'd be pulling the value from the DBCalc (sum hours) and DBField (Rate)
    and putting it into DBCalc (Total) I've tried this but no combination
    seems to work.

    Thanks!


  • edited July 2006
    Hi Jon,

    Using DBCalcs in other calculations can be difficult due to the timing in
    which they are finally calculated. I would recommend replacing all your
    DBCalcs with TppVariables and doing the calculations manually. For the
    DBCalc that calculates the sum (or Total A), you would simply place a
    Variable and in its OnCalc event add something like the code below. Notice
    that you can use this event to calculate a completely different value as
    well...

    procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
    begin
    Value := Value + ppReport1.DataPipeline['Hours'];
    ppVariable2.Value := Value * MyTable['Rate'];
    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2006
    Thanks Nico - Maybe using DBCalcs was my problem all along. I'll give it a
    shot!


This discussion has been closed.