Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to calculate the percentage of the GF2 variable to the RF variable

Status
Not open for further replies.

staceyn

Technical User
Nov 19, 2004
107
US
Hello,
I am using Crystal XI rel2 with an informix 10 database.
I have a main report with a subreport to pull sales data into an inventory listing report.
I have all of the shared variables working and giving me correct totals for each group and for grand totals.
The variables are passing sales quantites from the sub report to the main report. There are 2 groups defined in both the main and sub reports, class and style.

The report requires grand totals as well.
For the GF2(class) I have a variable for total sold by class. This calculates and resets correctly using accumulation, reset and display variable formulas.
I also have the variable for grand totals calculating and resetting correctly.

The GF2 formula
//@classtotalsolddisplay
whileprintingrecords;
shared numbervar sumclassqty;
sumclassqty

The RF formula
//@grandtotalsolddisplay
whileprintingrecords;
shared numbervar sumgrandqty;
sumgrandqty


Here is the problem.
I need to calculate a percentage formula called class mix.
This formula should be
//@classmix%
if sumgrandqty <>0
then sumclassqty/sumgrandqty *100.

I am getting 100% for the first class value and incorrect percentages for the remaining class totals.

Is there a way to get this percentage formula to calculate the correct mix%?

Any help is appreciated.

Thanks,
Stacey
 
YOUr Sumgrandqty is not grand total until end of report.

A quick solution is to add a sub report to report header which simply calculates Sumgrandqty. Minmises SR and do not let it grow.

This var can then be passed to main report as a shared variable and will allow you to calculates class %ages.

Ian
Ian
 
Hi Ian,
I tried as you suggested. I am getting the right value in the RH from the variable for the grand totals from the new subreport.
However, the percentages still aren't calculating correctly.
It is almost as if it is resetting on the group levels in the calculation.
Any other thoughts?

Thanks,
Stacey
 
Did you give it a new name or remove the old var formula.

If you did not rename and the old formula is still active then the shared var from the SR is being over written by the Shared var in main report.

As a rule only declare shared vars for passing between main and sub reports. Use Global vars within a report.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top