Focal Point
Suppress all but newest record

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7351087331

June 13, 2004, 05:18 PM
mulder75
Suppress all but newest record
I am reporting off of a table that holds records (events) of unit movements. Units move several times a day. The report I am building will show all units, sorted by location, but I only want to show each unit once, by it's newest movement record. Fields are: unit, location, date, time, owner. The preferred format would be:

Unit Location Owner Date Time
UnitB - New York - Bill - 06/13/04 - 2103
UnitD - New York - Jean - 06/13/04 - 2200
UnitC - Chicago - Roy - 06/12/04 - 1535
UnitA - KanCity - Jim - 06/13/04 - 2040

In reality, UnitB has 5 other movement records, all older than 06/13/04 2103 hours. Does anyone out there have a suggestion on how to do this?
June 13, 2004, 06:10 PM
drew billingslea
you might want to try

BY UNIT
...
BY HIGHEST 1 TIME

hth,

drew
June 13, 2004, 07:05 PM
mulder75
Drew:

Thanks for the suggestion. I have already tried that and it doesn't suppress the duplicates. I think if you have three movement records all showing the same date and time for a unit (it's possible) and those three records are newer than all the others, it outputs the line 3 times.
June 13, 2004, 07:20 PM
mulder75
Yes, I checked the data and that is exactly what it is doing. Even though I am telling it to report the highest (1) date and highest (1) time for the unit, it grabs all of them if they are the same...
June 13, 2004, 08:00 PM
drew billingslea
in that case you might want to try something like:

-* concat a unique key, you may have to convert your date and time to an alpha or whatever
DEFINE FILE yyy
U_KEY/A99 = LOCATION | USER | ... other fields ;
END

TABLE ...

BY HIGHEST 1 U_KEY


hth,

drew
June 13, 2004, 08:02 PM
drew billingslea
or you might even want to look at something like

WHERE LOCATION NE LAST LOCATION AND
USER NE LAST USER AND
DATE NE LAST DATE AND
TIME NE LAST TIME;

just an idea,

drew
June 14, 2004, 06:35 PM
susannah
Mulder,
use the lst. prefix operator
assuming you have sorted your file so that the latest date is the bottom of each unit paragraph
SUM LST.OWNER LST.DATE LST.TIME BY UNIT BY LOCATION

works like a charm

umm. can we expect a Scully, from your same org? Razzer
June 15, 2004, 07:26 PM
mulder75
Susannah:

My counterpart is not the right gender. Big Grin