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

Saving the first field/variable from a list of detailed records

Status
Not open for further replies.

DougNaf

Programmer
Jun 2, 2005
32
US
I have results from a crystal report such as

Number AppNo
123.44 100
222.66 100
456.44 100
095.00 200
105.00 200
109.11 200
088.00 205
099.02 205
887.11 205

i need to create a new column that has the top number from each AppNo:

Number AppNo NewNo
123.44 100 123.44
222.66 100 123.44
456.44 100 123.44
095.00 200 095.00
105.00 200 095.00
109.11 200 095.00
088.00 205 088.00
099.02 205 088.00
887.11 205 088.00

I think you get the idea. THANKS in advance for suggestions!
 
Group by AppNo
Create formula NewNo
minimum({yourdb.number},{yourdb.AppNo})

place that next to AppNo in details

hide or suppress group header and footer.


_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Create the following formula and place it in the Details section:

Code:
WhilePrintingRecords;
Global StringVar NewNo;

If      OnfirstRecord
Then    NewNo := {Data.Number}
Else
If      {Data.AppNo} = Previous({Data.AppNo})
Then    NewNo := NewNo
Else    NewNo := {Data.Number};

NewNo

This approach relies on the assumption that the records are in the correct order, such that the first Number that appears for a AppNo is the one you want to capture as the NewNo.

I have also assumed that Number is in fact text (because of the formatting with leading zeros etc). If it is numeric change the StringVar declaration to NumberVar.

Cheers
Pete
 
Thanks! I tried tested both suggestions and both work GREAT!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top