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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percentage Totals in Subreports

Status
Not open for further replies.

lighthouses4me

Programmer
Nov 10, 2003
3
US
Trying to find percentage of totals in each subreport and using a @grandtotal formula when trying to calculate percentages. The @grandtotal formula is developed using shared variables from the subreport to the main report. Then use that @grandtotal formula to calculate the percentage per person. It works for the first subreport. For all other subreports after that the variables for the @grandtotal formula is not passed. Any ideas?

From
lighthouses4me
 
Yeah, the first idea is to post where you're using these formulas (show the formula) and subreports.

Shared variables get passed between subreports, so you're either resetting them somewhere, or improperly referencing them.

-k
 
I have successfully used the knowledge base regarding
using a shared variable to pass info from the subreport to the main report. I wanted to go one step further to include percentage and it didn't work.

I have a main report with 10 subreports. Each subreport has a variable that is being passed to the main report to provide a total. In the main report I have the grand total of all the subreports which totals correctly. When I try to use the @GrandTotal in the formula to create percentage it only shows the percentage for the first subreport. For
subreports 2-10 the subreport totals are not passed. If I go back and delete the percentage formula then the subreport totals appear again.
What can I do to fix this?

The variables are placed in the main report and subreports report footers.

Grand Total Formula
mainreport total + subreport1 total + subreport2 total + subreport3 total + subreport4 total + subreport5 total + subreport6 total + subreport7 total + subreport8 total + subreport9 total + subreport10 total = GrandTotal

Percentage Formula
Total Hours by Name / @GrandTotal X 100 = %
 
I see no reference to shared variables in your formulas?

You mst always reference any shared variables used in every formula.

For instance:

Main Report:

RH
PH
GH1
DTL
GF1
RF1 (subreport sets shared variable S1)
RF2 (subreport sets shared variable S2)
RF3 (subreport sets shared variable S3)
RF4 (subreport sets shared variable S4)
RF... (subreports sets other shared variables...)
RF11 @total

@total formula
whileprintingrecords;
shared variable s1;
shared variable s2;
shared variable s3;
shared variable s4;
shared variable s5;
@total := s1+s2+s3+s4+s5 etc...

So when you set the shared variable in the subreport, make sure that you use the word shared, and anywhere you later wish to use it, do the same.

Also the subreports must fire before the shared variables are used, so create seperate report footers for the subreports and then afterwards, a seperate section for the total formula.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top