Home RAP

Calculations in a group band

edited October 2002 in RAP
Hi All,

My report has the following columns: Account, Regular, Overtime, Overhead,
EffectiveRate. It is grouped by Account. EffectiveRate is a calculated
field. In the detail band I added all the components for the fields and
added a TppVariable component for EffectiveRate and wrote the code for
calculation as Value := Src['Overhead'] / (Src['Regular'] + Src['Overtime'])
* 100. The detail works fine.

In the group band for Account I added TppDBCalc components to sum Regular,
Overtime and Overhead. How do I get the EffectiveRate and what component
should I use. As obvious, it should equate to Sum of Overhead / (sum of
Regular + Sum of Overtime) * 100.

I do not want to write any code in Delphi (like using OnCalc routine of the
dataset) as this report is part of a generic reporting application and I
would like to have any calculation code inside the reportbuilder template,
which I load dynamically when the user selects a report.

Thanks in advance.

Manan

Comments

  • edited October 2002
    Use RAP. I would code it in Delphi first to make sure the approach will
    work and then copy the event handler code to RAP, You can use TppVariables
    to perform the statistical calculations based on the DBCalcs values. The
    DBCalcs should fire before the variables in the same band. You can use all
    TppVariables, then if you want to control the order in which variables
    calculate, use their CalcOrder property to set the timing in which they fire
    their OnCalcs for a single band they are contained in. The CalcOrder
    doesn't work across mulitple bands.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited October 2002
    Thanks for the response.

    What I did was put a TppVariable component in the group band. The group band
    has another component AOHCalc which is a TppDBCalc. I wrote Value :=
    AOHCalc.Value in the Calculation for the TppVariable component. But the
    value always comes out to 0. What should I be setting in the Timing
    properties? Thanks in advance.

    Manan

  • edited October 2002
    You have to set the datatype property of the variable. The default datatype
    is string and this will result in a value of zero when you are trying to use
    it as a numeric variable.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited October 2002
    Excellent. Thanks a lot, Jim :-)

    Manan

This discussion has been closed.