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

Percent per detail line

edited August 2006 in General
I need something like this:
Percent
1 X 200 =200/950
2 Y 250 =250/950
3 Z 300 =300/950
Total: 950

I downloaded an example in the newsgroup. But I cannot open it. Can you just
tellme the trick.
I use RB10. D2006.

Thanks
Juan Jose

Comments

  • edited August 2006
    Hi Juan,

    Try the following example. I tested it with D2006 and RB 10.04 and it works
    correctly.

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

    There is no real trick. The example simply calculates the grand total for
    the first pass of the report and uses it to calculate the running percentage
    for the second pass.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2006
    I've got the example working now. But just in run-time. Thanks

    1. Is there a way to put the function inside the RAP instead of in Delphi?
    2. How can I be sure that I am calculating the percentage in the sencond
    pass?

    I have the report set up for two passes.
    I have the groups and amounts working fine.
    The total is sum(_CURRENT_MONTH') with LookAhead. The group total
    is shown on each row correctly.
    The OnCalc of the variable1 code is:
    Value := (ACCOUNTS['_CURRENT_MONTH']/DBCalc2.Value)*100;
    Variable1 calculates on "Transversal" and resets on the end of rhe group
    (The only group that I have).

    Should this work this way or I am missing something?

    I am short of ideas now.

    Thanks

    Juan Jose

  • edited August 2006
    Hi Jose,

    As a quick test I moved the code from the example in Delphi to RAP and
    everything seemed to work correctly. You will need to declair the
    FGrandTotal variable in the global declarations section of the Module View.
    Other than that, I copied the code directly from Delphi to RAP.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2006
    Thanks Nico,
    I did the same, but it is giving me weird results.

    I took off the grand total part and left only the group total and
    percentage.

    Please take a look to the simplified example I sent to the rap group, and
    try to figure out why it does not work.

    Thanks

    Juan Jose

  • edited August 2006
    Hi Jose,

    For future reference, please send all attachments to
    support@digital-metaphors.com.

    Sorry, I did not realize you wanted a percentage of a group total. The
    example I sent calculates a running percentage based on the sum currently
    calculated. If you would like a group percentage based on the group total,
    you will need to keep track of the group total in memory using a TList or
    TStringList object. Take a look at the following example on how this can be
    done. All of this code can be recreated in RAP.

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

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2006
    Ok
    Thanks and sorry for the attachment.
  • edited August 2006
    Let me try it out!

    Juan Jose

  • edited September 2006
    It is working now!

    Thank you!
    Juan Jose

This discussion has been closed.