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

how to solve a Min/Max-Calc in groupheader problem

edited May 2004 in RAP
Hello!

I've the following lines in a resultset

GroupID, Beginn, End, ...

1, 01.02.2004, 31.03.2004 ...
1, 01.01.2004, 29.02.2004 ...
1, 01.03.2004, 30.04.2004 ...
2, 01.02.2004, 31.03.2004 ...
2, 01.01.2004, 29.02.2004 ...
2, 01.03.2004, 31.05.2004 ...

Dates are in german DateFormat ('dd.mm.yyyy')

Now i want to calculate in the groupheader the following line (i.e for
GroupId 1)

01.01.2004 to 30.03.2004 = 121 Days
DbCalc1 DbCalc2 Variable1)

The date-fields are as dbcalc and look forward correct, but my variable
witch calculate the days between the min and max don't do correct.

In the rap i have the following small statement:

Variable1.AsInteger := (DbCalc2.Value - DbCalc1.Value) + 1;

I've tryed it in Variable1.OnCalc and Variable1.OnPrint but i never get the
days correctly
Wher i make the Variable look forward i get for each group the same value
(this is also wrong)

We have RB 7.02 and Delphi 7.

Greetings Ren?
Sorry about my bad english. I hope it's not to bad to understand my problem.

Comments

  • edited May 2004

    I can think of 2 techniques for implementing a solution:

    1. Create a summary SQL query that calculates the Min, Max for each GroupId.
    Link the summary to the detail. Then you do not need the DBCalc's with
    LookAhead, you can use DBText and TppVariable to perform simple calculations
    on the datafields.

    2. Perform the calculation using the look ahead values from the DBCalc. The
    following example shows how to use look ahead values in calculations:

    www.digital-metaphors.com/tips/CalcUsingLookAheadValuesRAP.zip

    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com


    Best regards,

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