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

Problem calculating two values

edited June 2005 in End User
Hi,

I have made a report that based on a customer account.

The report have the customer's number, name, payment, receivement and
total (receivement - payment)

The user choose the customer's number, the initial date and the final
date for the report.
Everything ok until now.

The problem is that I must calculate the sum of the Receivements -
Payments before the initial date, and put that value at the top of the
report, and for the total in the detail I must sum that value.

Ex. Initial Date: 01-01-2004
Final Date: 31-12-200

Value Before Initial Date: 200 (< 01-01-2004)

Receivement Payment Total
150 50 300 (150-50+200)
50 25 325
and so on...

The same situation for the value after the Final Date.
At the end at the report I have a value in the total and I must sum the
value after 31-12-2004.

How can I do that?

Thank you all

Isildo Mendes
Portugal

Comments

  • edited June 2005
    Hi Isildo,

    Try placing a TppVariable component in the Total column and inside its
    OnCalc event, set its value equal to the sum of the other values in the row
    as well as update the value of another variable located in the header (with
    LookAhead set to True). This should give you the effect you are after.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2005
    Nico Cizik (Digital Metaphors) escreveu:

    Sorry, but I didn't understand.

    The total in the detail is already a variable that makes the difference
    between the payment and the receivement. My problem is how to reach that
    value where the date is before the initial date, and that same value,
    but where the date is after the final date.

    The report just show me the records between the initial date and the
    final date.

    Thanks again

    Isildo Mendes
    Portugal
  • edited June 2005
    Hi Isildo,

    If you would like to show the value of a calculation before the calculation
    has occured (for instance in the header band) you can do so by making sure
    the LookAhead property of the variable in the header band is set to true and
    you report is set to TwoPass.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2005
    Nico Cizik (Digital Metaphors) escreveu:
    Hi again,

    Maybe I'm not giving you the right information.

    We have several reports (rtm files). In each report we one or several
    dataviews. In the application the user choose the report, and then,
    based on the data dictionary he can choose what fields to filter the
    data in the report. We stored that values to build a where clause to
    modify the sql in the report. So in this particular report, the user
    chooses the customer number and the initial and the final dates. So the
    report will show only the records that meet that conditions. Now, how
    can I calculate a value, at run-time in the report, that is outside that
    conditions? Maybe I don't understand how reportbuilder works.

    select sum(value) from table
    where date < initial_date

    select sum(value) from tabela
    where date > final_date

    I put a variable in the report header to calculate that value, but how
    can I 'say' to that variable to do the calculations only for records
    that have the date before the initial_date?

    And a variable in the summary that make the same calculation, but only
    for records that the date is after the final date?

    Thank you for your attention

    Isildo Mendes
    Portugal
  • edited June 2005
    Hi Isildo,

    Ah... thank you for the clarification :).

    ReportBuilder only traverses the data given by the dataset it is connected
    (in your case, the dataview filtered on two dates). If you would like to
    make a calculation using data other than the data sent to the report, it
    will need to be done outside of ReportBuilder in your main app.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.