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!

Running Total / Maximum Value Headache

Status
Not open for further replies.

craigK

MIS
Mar 28, 2001
71
US
I'm trying to sum together a group of data, then pick the largest value to sum.

My data looks like this.

detail:
yellow 10
yellow 15
yellow 25
blue 10
blue 15
blue 25
red 10
red 10
red 20

report grouping 1: (sum of detail)
yellow 50
blue 50
red 40

report grouping 2: (Max of group 1)
50

i'm using a running total to get the sum of detail and that works fine. But I can't get the max of the sum to work. Is there a way to expand on this formula to get the maximum value after grouping.

whileprintingrecords;
numbervar rtsum := 0

whileprintingrecords;
numbervar rtsum := rtsum + {tAgentLoggedIn}

whileprintingrecords;
numbervar rtsum

 
Create a formula to evaluate after each group is summed:

global numbervar maxtotal;

if maxtotal < #runningtotal then
maxtotal := #runningtotal
else
maxtotal := maxtotal;


You will need to initialize maxtotal before you use it, and create another formula to display it.. but I think that should give you enough to go on.

Lisa
 
How do i get the formula to evaluate after the group is summed? Any max formula i try always returns detail records and not the summary total.
 
This evalutates the max manually. You don't use the Max function at all..

It holds a value that it thinks is the max. When you place the formula in the group footer each time that footer is reached it looks at what it thinks is the max along with the current group total. If the group running total is larger, then that becomes the new max.. otherwise it keeps what it had.

Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top