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!

Average in Group Footer

Status
Not open for further replies.

old123

MIS
Jun 1, 2005
31
US
Crystal Version 9
Database AS400

Existing Report

Bus no Mileage Differnce

PB0001 79243
PB0001 84739 5,496.00
PB0001 90445 5,706.00
PB0001 96393 5,948.00
PB0001 101853 5,460.00
PB0001 107828 5,975.00
PB0001 113590 5,762.00
PB0001 119600 6,010.00
PB0001 125031 5,431.00
PB0001 131078 6,047.00
PB0001 137012 5,934.00
PB0001 142839 5,827.00
PB0001 148605 5,766.00
PB0001 154616 6,011.00
PB0001 160236 5,620.00
PB0001 165870 5,634.00
PB0001 171609 5,739.00

Count XXXX Avg XXXXX

PB0002 108397 0
PB0002 113609 5,212.00
PB0002 119590 5,981.00
PB0002 125218 5,628.00
PB0002 130874 5,656.00
PB0002 136585 5,711.00
PB0002 141935 5,350.00
PB0002 147633 5,698.00
PB0002 153687 6,054.00
PB0002 159670 5,983.00
PB0002 165490 5,820.00
PB0002 171302 5,812.00
PB0002 177473 6,171.00
PB0002 183311 5,838.00
PB0002 188964 5,653.00
PB0002 194636 5,672.00
PB0002 200407 5,771.00
PB0002 205613 5,206.00

Count XX Avg XXXXX

Differnce is calculated by this formula

IF {FM_300L2.FMASET} = PREVIOUS({FM_300L2.FMASET}) THEN
(
if {FM_300L2.FMPMR} >= PREVIOUS({FM_300L2.FMPMR}) then
{FM_300L2.FMPMR}- PREVIOUS({FM_300L2.FMPMR}) else
{FM_300L2.FMPMR}
)
ELSE
0

Avg is calculated :

whileprintingrecords;
numbervar summiles;
numbervar counter;
if counter > 0 then summiles/counter else 0

Avg formula is residing in Group Footer 1

Expected Output

I want to show the average mileage distance in the Report Footer for all the buses . I want to show seperately for each bus(current output) & for the whole Fleet(Expected Output).
I need to show the avergae of all Group Footer . & i have approx total 140 subgroups
Any help / suggestions


 
If you want a recap by bus at the bottom, I would place a simple crosstab report object there.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
I already have average by bus , i need to find avergae of the whole fleet.
Report purpose is to find mean distance of failure for whole fleet.

I calculated mean distance for each bus & now i need to find avg mean distance for all the buses.

Does it make any sense.
 
It's important to know whether you want the average across all buses, or the average of the averages per bus. Assuming you want the first, then change your formula to:

whileprintingrecords;
numbervar summiles;
numbervar counter;
numbervar grtotmiles := grtotmiles + summiles;
numbervar grtotcnter := grtotcnter + counter;
if counter > 0 then summiles/counter else 0

Then in the report footer, add a formula:

whileprintingrecords;
numbervar grtotmiles;
numbervar grtotcnter;
if grtotcnter > 0 then
grtotmiles/grtotcnter else 0;

This assumes that you have a reset formula in your group header:
whileprintingrecords;
numbervar summiles := 0;
numbervar counter := 0;

...and that summiles and counter are being accumulated in another formula.

If you wanted the average of the average, then you would also use a variable to sum your formula

whileprintingrecords;
numbervar summiles;
numbervar counter;
numbervar ave;
numbervar sumave;
numbervar grtotcnter := grtotcnter + 1;
if counter > 0 then
ave := summiles/counter else
ave := 0;
sumave := sumave + ave;
ave;

Then use a display formula like:
whileprintingrecords;
numbervar sumave;
numbervar grtotcnter;
sumave/grtotcnter

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top