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.
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?
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.
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.
Comments
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
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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
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
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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
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
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks and sorry for the attachment.
Juan Jose
Thank you!
Juan Jose