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

Calculating %

edited July 2002 in General
Hi,

I am using RB6.03 and D5 to calculate the %
I will give an example of what I need:

Value %
1) 100 10
2) 200 20
3) 250 25
4) 350 35
5) 100 10
Total 1000 100%

How can I set up a ppVariable field to calculate the % column.


Thanks,
Clément

Comments

  • edited July 2002
    Check out the demo below.

    http://www.digital-metaphors.com/tips/PercentageOfGroupTotal.zip

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited July 2002
    Hi Alexander,

    Thanks for you assistance.

    Is there any way of doing this inside the report?
    I had already seen this tip and tried to use Calc section.
    I was hoping there was a tip on using it

    My report has 2 sections.
    Section one is the main dataset with a pipeline.
    Section two is a subreport placed inside the detail band of section one.
    The data linked and shown correctly.
    The problem is this percentage of total column.
    This is the code I am using inside the report:

    procedure PrecGrupoOnCalc(var Value: Variant)
    begin
    if Report.SecondPass then begin
    {ShowMessage('Second pass');}
    if GroupTotal.Value<>0.0 then
    Value := {100 * JobsCustos['ESTIMADO_TOTAL'] /} GroupTotal.Value
    else
    Value := 0.00;
    end;
    end;

    If I set ppReport to 1 pass then the Percentage column (SubReport) isn´t
    calculated. (displays 0.0%)
    If I set ppReport to 2 passes then the Percentage column is accumulated.
    If I set ppReport to 2 passes and the ChildSection to 2 passes then in
    preview the pass of the ChildSection is set automatically back to one
    while the report is generating, and back to two once it´s ended.

    The above is fired but returns an unexpected result.

    What am I missing?

    Regards,
    Clément



  • edited August 2002
    Since you're using a master detail setup then I am assuming that your
    'group' lies within the context of a detail subreport. In this case your
    calculations are limited to within the subreport. You should be able to do
    group totals then by keeping a total for the subreport and then performing
    the calculation pretty much as you have below. The subreport must be two
    pass because on the second pass is when the calculation takes place. Whether
    the main report is one or two pass doesn't have any effect on this since all
    your calculation are taking place within the context of each detail
    subreport.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited August 2002

    But this is exactly the problem.
    I set the TppSubReport to two passes and when previewing the report the
    object inspector show the passSetting property going to One (generate
    the report) and back to two (once its done). Why?

This discussion has been closed.