Solved

How to Average a Group Maximum Values

Posted on 2011-03-25
3
209 Views
Last Modified: 2012-05-11
I have a report that is grouped on a LoadID field (multiple rows per LoadID, each row containing a Mileage field).  For each LoadID group, I use a running total to display the maximum Mileage for that LoadID.

Now, in the footer of the report, I want to put in the average of these Maximum values (i.e. average the maximum Mileage for each LoadID). I can't use a running total or a summary field on the running total field that I used to display the maximum mileage per load, as per Crystal capabilities.  

Any suggestions/questions?
0
Comment
Question by:jhardwood
  • 2
3 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 35215388
You will need to use a manual average using formulas and variables.

In the report header add a formula to declare the variables
WhilePrintingRecords;
Global NumberVar RecCount;
Global NumberVar MileageTotal;
""

In the group footer add a formula to calculate the total
WhilePrintingRecords;
Global NumberVar RecCount;
Global NumberVar MileageTotal;
RecCount := RecCount + 1;
MileageTotal := {&MaxRunningTotal};
""

In the report footer add a formula to calculate and display the average
WhilePrintingRecords;
Global NumberVar RecCount;
Global NumberVar MileageTotal;
If RecCount > 0 then
    MileageTotal / RecCount
Else
    0

mlmcc
0
 

Author Comment

by:jhardwood
ID: 35217249
Excellent!  Worked Great!  I id have to change the MileageTotal calculation in the group footer formula to

MileageTotal := MileageTotal + {&MaxRunningTotal}

Without that change, the MileageTotal was alwas equal to the value of the last row.

Thanks again!
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35217328
Sorry.  Typing too fast.

mlmcc
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question