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

average on manual running total

Status
Not open for further replies.

pko123

Programmer
Apr 17, 2007
27
US
Hi,
i have a report in which , I have 3 groups
Code:
Group 1 (Region)                              Avg 1(Avg 2)
    Group 2 (City)                            Avg 2(Avg 3)
         Group 3 (Name 1)                     Avg 3 = 8
                           Name      Number
            detail 1       John        8
            detail 2       John        8
         
         Group 3 (Name 2)                      Avg 3 = 9
                           Name      Number
            detail 1       peter       9

in detail i have duplicates that's why i created 3rd group. What i am looking for is to get the Average of number on each group level. I ried using manual running total but its not working properly. also tried to use summary fuction, the problem i am facing is summary fuction is calculating sum for all the details not for unique. BTW i don't need to show details. Only reason i created group 3 is in oredr to get rid of duplicates.

Please let me know, Any sugestions
 
Which version of Crystal? When you say manual running total, does this mean a formula? If so, please post it.

At least in version 10, Crystal's automated running totals had enough functions to do the job. Add once per group, for instance.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
If you are okay with showing the averages in the group footers, you can use formulas like these:

//{@resetavg1} to be placed in GH#1:
whileprintingrecords;
numbervar sum1;
numbervar cnt1;
if not inrepeatedgroupheader then (
sum1 := 0;
cnt1 := 0
);

//{@resetavg2} to be placed in GH#2:
whileprintingrecords;
numbervar sum2;
numbervar cnt2;
if not inrepeatedgroupheader then (
sum2:= 0;
cnt2 := 0;
);

//{@accumavg2} to be placed in the GH#3:
whileprintingrecords;
numbervar sum2 := sum2 + average({table.number},{table.name});
numbervar cnt2 := cnt2 + 1;

//{@displavg2} to be placed in GF#2:
whileprintingrecords;
numbervar sum2;
numbervar cnt2;
numbervar avg2 := sum2/cnt2;
numbervar sum1 := sum1 + avg2;
numbervar cnt1 := cnt1 + 1;
avg2

//{@displavg1} to be placed in GF#1:
whileprintingrecords;
numbervar sum1;
numbervar cnt1;
numbervar avg1 := sum1/cnt1;
avg1

-LB
 
Hi,
Thanks
for replies,

I am using Crystal XI, I tried using running total but problem is , i want to show averages in the header and by using running total i can't show avg in the headers,

any suggestions?

Thanks in advance
 
i was trying manual running total method but i am not sure weather that is the right approach or not, so if you have any other approach please let me know.

thanks
 
If you want averages of averages, then you either need to display the results in the group footers, or you can use the suggestion I gave you above in subreport that you can then place in the appropriate group headers.

-LB
 
LB,
Sorry i think i was not clear enough,
Avg 3 is not average at detail level. its just one of the number at details level, as records at the detail level have duplicates, but i need only one record,

for example avg3 = number (detail 1 or detail 2)
AVG 2 is average of above all number(avg 3) for all group 3 under group 2
AVG 1 is average of above all number(avg 3) for all group 3 under group 1



 
That is what I understood. Even if your "avg3" is the detail record that you have placed in the group header #3, that will be the same as the formula I showed.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top