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

Sum of a Summed Group Problem 1

Status
Not open for further replies.

mmck1964

Technical User
Jul 12, 2001
104
US
I am having trouble summing a summed group. Group 1 is based on a Reading Route, Group 2 is based on the Meter Number, The Detail section has the Meter Readings for the Group 2 Meter Number. The GF2 sum is working fine, but I also would like to sum all of the GF2's in GF1. The answer I get in GF1 is the last GF2 value, not the Sum of all the GF2 values.

Below is what I have that is not working.

GH1 {Reading Route}
GH2 (Meter Number}
Detail {Meter Readings}
GF2 {@_Sum of Meter Readings} "This works fine"
GF1 {@_Sum of GF2} "This is not working"


Below are the formulas for Group 1:
//GH1
whileprintingrecords;
numbervar grp1sum := 0;

//GF1
whileprintingrecords;
numbervar grp1sum := grp1sum + {@f_G2Footer};

Thank you for any help.



 
Instead of summing the sums for group 1, you should be able to sum the meter readings for group 1. So, you'll sum the meter readings at two levels - both group 2 and group 1.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
I tried that suggestion, and it does not seem to work.
Below is what I have now in GF1 and it only sums the last record in GF2. It also is what I have in GF2, which works fine for each meter. I just want to sum all of what is summed in GF2 in GF1.

//(@displaydiff} to be placed in the group footer:
whileprintingrecords;
numbervar first;
numbervar last;
numbervar diff := if (first > last) then
((100000 - first)+ last)*{BI_INTERVAL_RDGS.BI_MTR_MULT}else
(last-first)*{BI_INTERVAL_RDGS.BI_MTR_MULT};
numbervar sumdiff := sumdiff + diff;
diff
 
You are only showing part of what you are doing. The principles are these:

1-Reset formula --goes in the group header corresponding to the group level where you want the result, i.e., a group #1 summary requires a reset in the group #1 header, e.g.:

whileprintingrecords;
numbervar x;
if not inrepeatedgroupheader then
x := 0;

2-Accumulation formula -- goes in the section that contains the value you want to accumulate at the higher group level, e.g., if you want to summarize group #2 results at the group #1 level, then the accumulation formula goes in a group #2 section (probably the group footer), e.g.,

whileprintingrecords;
numbervar x := x + {@amt}; //{@amt} could be a group#2 calculation

3-Display formula-- goes in the group footer of the group where you want the result. In this formula, you only reference the variable in the accumulation formula.

whileprintingrecords;
numbervar x;

-LB
 
Here is what I have in the report, some GH1 and GF1 changes as i have been trying different things based on searching other posts.

//GH1:
whileprintingrecords;
numbervar x;
if not inrepeatedgroupheader then
x := 0;

//GH2:
whileprintingrecords;numbervar first;
numbervar last;
if not inrepeatedgroupheader then
(first := 0;
last := 0);

//Detail:
whileprintingrecords;
numbervar first;
numbervar last;
if {BI_INTERVAL_RDGS.BI_INTERVAL_RDG_DT_TM} = minimum({BI_INTERVAL_RDGS.BI_INTERVAL_RDG_DT_TM},{BI_INTERVAL_RDGS.BI_MTR_NBR}) then
first := {BI_INTERVAL_RDGS.BI_RDG};
if {BI_INTERVAL_RDGS.BI_INTERVAL_RDG_DT_TM} = maximum({BI_INTERVAL_RDGS.BI_INTERVAL_RDG_DT_TM},{BI_INTERVAL_RDGS.BI_MTR_NBR}) then
last := {BI_INTERVAL_RDGS.BI_RDG};

//GF2:
whileprintingrecords;
numbervar first;
numbervar last;
numbervar diff := if (first > last) then
((100000 - first)+ last)*{BI_INTERVAL_RDGS.BI_MTR_MULT}else
(last-first)*{BI_INTERVAL_RDGS.BI_MTR_MULT};
numbervar sumdiff := sumdiff + diff;
diff

//GF1
whileprintingrecords;
numbervar x := x + {@f_G2Footer};
 
FYI: The GF2 stuff all works just fine. I wanted to add GF1 to sum GF2 based on grouping all of the meters into the reading route group.
 
Your GF1 formula should simply be:

//{@display}:
whileprintingrecords;
numbervar sumdiff;

//GH1 - Reset:
whileprintingrecords;
numbervar sumdiff;
if not inrepeatedgroupheader then
sumdiff := 0;

-LB
 
Thank you lbass. I was trying to make it too difficult. The simplest things can be difficult if you don't understand.

 
Just one more thing, How can I total the group footer 1 sums?
Below is what i have, but it only displays the last GF1, not the sum of all GF1's.

whileprintingrecords;
numbervar sumdiff;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top