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!

formula to calculate the grandtotal of summaries 1

Status
Not open for further replies.

sugu

Programmer
Jan 12, 2004
90
SG
Hi,

I have 1 main report which uses 1 table and a subreport using another table. Both tables r linked by time.

The report displays the summary of abt 40 users' activities bet 12am till 11.45pm. And then i need to get the grand total for each field.

My problem is:

1) how do I generate the grandtotal value? I can't possibly create a formula like: Sum(Sum({fieldName})) for the grandtotal. Is there anyway to get a grandtotal for a formula?

2)How to display the grandtotal of the subreport fields in the main report?

regards,
 
You should be able to right click on the field (or detail-level formula) you want to summarize in the main report and insert a grand total without needing to use a variable.

For the subreport values, you should create a formula within the subreport that sets a shared variable to the subreport total:

whileprintingrecords;
shared numbervar subrpttot := sum({table.amt});

This must be placed somewhere on the subreport. I'm assuming that your subreport is placed in a group header section and linked to the main report on the group field.

Then in the main report, create three formulas:

//{@reset} to be placed in the group header above the section in which the subreport is located (insert another section if necessary and suppress it). This formula will take care of any nulls so that previous subreport totals are not carried forward in the case of nulls:
whileprintingrecords;
shared numbervar subrpttot := 0;

//{@accum} to be placed in the group footer section:
whileprintingrecords;
shared numbervar subrpttot;
numbervar sumsubrpttot := sumsubprttot + subrpttot;

//{@display} to be placed in the report footer:
whileprintingrecords;
numbervar sumsubrpttot;

-LB
 
thanks LB! i got it working
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top