Solved

How to Average a Group Maximum Values

Posted on 2011-03-25
3
208 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Speed Up Crystal Report 5 56
Can I add a checkbox function/control button in Crystal Reports ? 4 68
Crystal Reports Version 7 4 27
free Crystal Report viewer 4 20
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. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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