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

Can I get the Minimum and Maximum value on a page? 1

Status
Not open for further replies.

chadau

Programmer
Nov 14, 2002
155
US
I want to display the minimum and maximum values per page. I know there is the Minimum and Maximum Summary function built in, but that only works for the whole report. Thanks in advance for any advice.
 
You will have to set up variables to hold the max and min values and then use a detail line formula to compare the current value with the max and min values so far. Then print them in the footer using more formula fields.

To do this:
Create a formula field in the page header which defines the variables and sets then to extreme values.(eg. set the max to -999999 and the min to 999999.
This formula goes in the page header and can be suppressed.
The detail line formula must compare the currenyt value of the fiel with the max value and the min value. If it's graeter than the max then set the max to the current value; if it's less than the min then set the min to the current value.

In the page footer, create two formulas; one to show the current value of the max variable and the other to show the current value of the min variable.

I think you will have to use WhilePrintingRecords at the start of each formula.

 
I would create four formulas:

//{@reset} to be placed in the page header:
whileprintingrecords;
numbervar min := 0;
numbervar max := 0;
numbervar counter := 0;

//{@minmaxaccum} to be placed in the detail section:
whileprintingrecords;
numbervar min;
numbervar max;
numbervar counter := counter + 1;

if counter = 1 then min := {table.amt} else
if {table.amt} < min then min := {table.amt} else
min := min;
if counter = 1 then max := {table.amt} else
if {table.amt} > max then max := {table.amt} else
max := max;

//{@displaymin} to be placed in the page footer:
whileprintingrecords;
numbervar min;

//{@displaymax} to be placed in the page footer:
whileprintingrecords;
numbervar max;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top