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

MAX & MIN 1

Status
Not open for further replies.

reidtw

MIS
Feb 10, 2004
74
0
0
GB
Hi, using cr8 and sql2k db.

Can't seem to get this right: -

I have two groups 1. SecId, 2. Deal Type

Deal Type has two values B or S

I need to return the minimum price amount for B in group footer for SecId but unsurprisingly it's not working!

I have the following formulas: -

GH2
//@Price_Min_Reset
whileprintingrecords;
numbervar Price01:=0;

Detail
//@Price_Min
whileprintingrecords;
numbervar Price01;
Price01:= if {DealType} = "B" then minimum({@PRICE},{DealType});

GF1
//@Price_Min_Display
whileprintingrecords;
numbervar Price01;

Because Deal Type "S" is always after "B", zero values are returned for it and the display formula is always zero, I can't seem to populate with the correct value.

What am I not doing? I've tried running totals, the lot to no avail!

Some help would be great.
Trevor
 
One option is to create a Running Total with a formula of Type = B to control what records are evaluated.

- Ido

view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Use the running total as Ido suggested, or change your detail formula to:

whileprintingrecords;
numbervar Price01;
if {DealType} = "B" and
(
onfirstrecord or
{@PRICE} < Price01
) then
Price01 := {@Price};

-LB
 
Thanks for your input both of you, I plumped for the running totals on the correct group and it worked fine!

Thanks again,
Trevor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top