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

Sum of Group Total formula required in Grand total

Status
Not open for further replies.

CalgaryCR9

Technical User
Aug 12, 2005
80
CA
In previous posts I got my very convoluted report doing a group total average with this formula:

formula name: @average_closed_display_footer -->inserted in group 2 footer.

whileprintingrecords;
numbervar cnt_closed;
numbervar sumdiff_closed;
if cnt_closed > 0 then
sumdiff_closed/cnt_closed

It has a reset formula in group 2 header:

// reset
whileprintingrecords;
numbervar cnt_closed;
numbervar sumdiff_closed;
cnt_closed:=0;
sumdiff_closed:=0


Sample Data is:

270155 UID=Joe
1591942 UID=Fred
625736 UID=Mary
849718 UID=Paul
675896 UID=Rachel (UID is group 2, Role is Group 1) --Data/report design to this point is not problematic.

The total of the above numbers s/b 4,013,447 (unless I mis-added).

How do I get that total of 4,013,447 to appear in the group1 footer and/or the grand total?
I also want to divide 4,013,447 by GROUP 1:{DistinctCount Service_Call.Assigned_UID} that is in the Group1 footer. eg:4,013,447/5= 802689.4

I apologize for all the interuptions I've had in writing this report that makes me lose my train of thought, resulting in yet one more post for this report! :)
 
Add a different variable for each level, with a corresponding reset. You did not show the detail level formula that sets the values of sumdiff and cntclosed, and that is the formula you need to change. I'll make one up:

whileprintingrecords;
numbervar cnt_closed := cnt_closed + 1; //grp2 level
numbervar sumdiff_closed := sumdiff_closed + datediff("d", {table.orderdate},{table.shipdate}); //grp2 level
numbervar sumdiffgrp1 := sumdiffgrp1 + datediff("d", {table.orderdate},{table.shipdate}); //grp1 level
numbervar cntclosed1 := cntclosed1 + 1;grp1 level
numbervar grdiff := grdiff + datediff("d", {table.orderdate},{table.shipdate}); //grand total level
numbervar grcntclosed := grcntclosed + 1; //grand total level

Then in the group 1 header add:

whileprintingrecords;
numbervar sumdiffgrp1 := 0;
numbervar cntclosed1 := 0;

In the Group 1 footer, use:

whileprintingrecords;
numbervar sumdiffgrp1;
numbervar cntclosed1;
if cntclosed1 > 0 then
sumdiffgrp1/cntclosed1

In the report footer, add:

whileprintingrecords;
numbervar grdiff;
numbervar grcntclosed;
if grcntclosed > 0 then
grdiff/grcntclosed

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top