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

Finding the maximum of a crystal report running total field 1

Status
Not open for further replies.

racskelly

IS-IT--Management
Apr 19, 2007
37
CA
this is a two part question

my raw data looks like this

sales amount running total
jun 1 1 1
jun 15 -1 0
jul 1 10 10
aug 1 -8 2

i want to find the maximum running total amount plus the date on which it occurred - in this case max = 10 on July 1.

any suggestions?
 
How did you derive your running total? There might be some easier way. Possibly Crosstabs.

Otherwise I think you could do it with variables, which could store both a date and the value of the running total, updating the date when it found a running total larger than the one it stored.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
I would use variables

@Eval
global numbervar maxrt;
global datevar maxdate;

If RT >= maxrt then maxrt:= RT;

If RT >= maxrt then maxdate:= datefield;

Place this in same section as when RT displays and suppress formula.

You can then use formula to display in report footer

@maxrt
global numbervar maxrt;

If this is within a group you will need to include a reset in group header

@reset
global numbervar maxrt:=0;
global datevar maxdate:=date(1900,1,1);

Ian
 
For other readers, note that each of the formulas above must be preceded by "whileprintingrecords;" for the formulas to work properly. Note also that "global" does not need to be explicitly stated since "global" is the default variable type, so it could safely be removed from all formulas (though it doesn't hurt anything to include it).

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top