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

Calcuating In RAP

edited November 2005 in RAP
Hi guys

Wonder if you can help with this one

I have a report that is grouped and returns to records by group.

Example output below

Desc Value Date
Widgets 100 01/05/05
Widgets 50 01/07/05

What I want to be able to do is for each group divide one record by the
other to get a percentage

EG Divide 50/100 to get 0.5 that I can display as a percentage.

I am sure this can be done but am getting a little confused with variables
and timings etc.

Hope this is the correct forum for this sort of question

Cheers and thanks in advance

Mark

Comments

  • edited November 2005
    Hi

    We have had the same problem. I searched the newsgroup, and found the
    following links usefull

    http://www.digital-metaphors.com/tips/UseLookAheadValueInCalc.zip Date: jun
    16 2003 - 8:30pm
    http://www.digital-metaphors.com/tips/PercentageOfGroupTotal.zip Date: apr 2
    2003 - 7:08pm

    The dates are there too if you wish to review the questions asked

    Best regards
    Steffen

  • edited November 2005
    Thanks fot this. I already had found these too but they did not really help.

    1. I need to find a solution in RAP.
    2. I am trying to divide the field in record A with a field in Record B of
    that group. The examples are always using grandtotals that I will not be
    using.

    My group will always only have two records in it due to the nature of the
    data and query. So i need to divide one by the other to get a percentage.

    Basically this data is value by date eg sales figure. My client wants to see
    how the sales data changed as a percentage and im struggling to resolve.

    Cheers for any help

    Mark


  • edited November 2005
    Hi Mark,

    When you say you need the percentage of two group values, are these values
    directly from your dataset, or are they calculated in your report and
    displayed perhaps in a Group Footer band? If you would like to calculate a
    percentage of two records in your detail band, you can do so simply using
    the OnCalc event of a TppVariable also placed in that band. Something like
    the following...

    Value := Report.DataPipeline['Field1'] / Report.DataPipeline['Field2'];

    Perhaps a little more information on how your report is set up and what you
    would like it to look like would help.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Nico

    I gave an example in the first post. In your example below I would need to
    do
    Value := Report.DataPipeline['Field1'] / Report.DataPipeline['Field1'];

    This is hard to do I think ?? As I have said my report group will always
    return two values due to the nature of the query.

    1. User selects one date for one record
    2. User selects one date for second record

    select * from something where date = date1 or date = date2

    group this by say salesrep and we have two records per sales rep.

    Sales Rep1
    Widgets 100 date1
    Widgets 200 date2

    Sales rep2
    Widgets 100 date1
    Widgets 200 date2

    What I need to do is show the percentage difference between the two dates so
    for sales rep 1 it would be (200/100) * 100

    I have actually fixed my problem by doing two datasets and linking them
    together so that I can get all my data onto one record and calc from there.

    The problem above is that the data is over two records and I need to calc on
    the same field from different records.

    If you can help solve this I would be interested and very grateful

    Cheers

    Mark



  • edited November 2005
    Hi Mark,

    If there is always going to be two dates to deal with you could simply
    create two global integer variables and store the values for later use (i.e.
    calcualting the percentage difference between the two).

    If there is a chance there is more than two dates to deal with, RAP does
    support list objects such as the TStringList. You could create a global
    string list and store each value from the dataset per group inside. Then
    once you need to percentage difference you could access that data and make
    the calculation.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    This is a multi-part message in MIME format.
  • edited November 2005
    This is a multi-part message in MIME format.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    This is a multi-part message in MIME format.
  • edited November 2005
    This is a multi-part message in MIME format.
    Best Regards,

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