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

Last and Last but One 1

Status
Not open for further replies.

Deleco

Programmer
Feb 25, 2002
109
GB
Hi people,

I have a list of records as follows

Code:
0007	16/01/2003	3	Surv
0008	10/07/2003	5	Surv	
0012	10/01/2005	3	Surv
0015	10/05/2005	3	Surv

What i have been asked to do is compare that last surveillance with the last but one surveillance. So what i want is a formula i can use or something that allows me to suppress the second to last and all others before the last but one. So for this example all i would like to see is

Code:
0008	10/07/2003	5	Surv	
0015	10/05/2005	3	Surv

Any help would be appreciated.
Thanks

Deleco
 
Create a group on the datefield in descending order and then use the Group sort expert to select the top 2 groups.
You can suppress the group header.
 
Hi wouldn't that give me the bottom 2

Code:
0015    10/05/2005    3    Surv
0012    10/01/2005    3    Surv

I need the last (oops just realised my mistake) surveillance and the surveillance that happend before the last but one surveillance.

Hope that makes sense. What i need is the last record and then suppress the record before last, show the next one and then suppress all others. Is this possible

Deleco
 
Sort descending and it will return only thw 2 newest dates.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Let's say that you need to compare these records within multiple groups. Create a running total {#cntwingrp} that does a count of {table.code}, evaluates for each record, and resets on change of group (whatever your group is). Then you can go to the section expert->details->suppress->x+2 and enter:

{#cntwingrp} <> count({table.code},{table.group}) and
{#cntwingrp} <> count({table.code},{table.group})-2

-LB
 
Ok i can done that thanks

I returned 3 records, now i need to suppress the middle/2nd one.

For example below.

Code:
3 Surv
2 Surv
1 Surv

I only need 3 and 1

Code:
3 Surv
2 Surv
1 Surv




Deleco
 
Please explain why you want the middle one out of the report. Also explain "last but one" that makes no sense to me. I too this to mean "next to last".

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Who are you responding to? My suggestion should work.
If you don't have a group, have the running total set to reset never, and remove the group condition in the suppression formula.

-LB
 
lbass

Thanks your method appears to be working. I now just have to change it slightly to work with odd numbers of records as well.

Thank you all for your help

Deleco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top