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!

Help Selecting Top Record in a Group 2

Status
Not open for further replies.

BillMck

Technical User
Apr 29, 2004
4
0
0
US
I need help to select the top record (one with the most recent date) in a groups of records that are grouped by ID number. I have grouped records by ID number, but can't figure out how to select the most recent record for each person to be output onto my report.

Any help would be appreciated. I am a new to using Crystal Reports. Using version 9.0.
 
There are several ways you can do this:

1) Sort dates in descending order and drag the details into a group header section and then suppress the details. Or,

2) Go to report->edit selection formula->GROUP and enter:

{table.date} = maximum({table.date},{table.ID})
//where {table.ID} is your group field. Or,

3) Go to the section expert (format->section)->details->suppress->x+2 and enter:

{table.date} <> maximum({table.date},{table.ID})

-LB
 
I am note sure if this can help.

Can I suggest to put 1 more group/order by date for each person? If you group/sort the record by date in desc order, then the first record will be most recent record.

group by id
group/sort by date in desc order
print the first record when id change

Put the formular to suppress detail in section format and the sample formular to check id change:
shared numbervar previous_id;
booleanVar suppress_dtl;

if shared numbervar previous_id <> {Current ID number} then
(
shared numbervar previous_id = {Current ID number};
suppress_dtl := false;
)
else
(
suppress_dtl := true;
)
shared numbervar previous_id = {Current ID number};

suppress_dtl;

 
Thank you both for you ideas I will try them and see if I can get them to work. Another thing that I would like to do is to sum up an account balance that is in the most recent record for each person's ID in a grand total. Using your procedure, can I also do that?
 
I tried the 2nd solution that LBass provided. It was very easy to do and worked perfectedly. Interesting it also correctly then summed up the account balance field perfectly (only for the top record in each group.

I am extremly greatful to both LBass and 700503 for all their help.

This website is the best help on the internet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top