Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Flag records missing a matching 'next' record Post Reply Post New Topic
Author Message
mfergel
Newbie
Newbie


Joined: 13 Apr 2011
Online Status: Offline
Posts: 6
Quote mfergel Replybullet Topic: Flag records missing a matching 'next' record
     Posted: 13 Apr 2011 at 7:37am

I have a series of data in a report that looks like the following:

827,489     
Start Date/Time 8/18/2010 3:23:57 PM 0.00 0.00 1
Stop Date/Time 8/18/2010 4:35:19 PM 72.00 72.00 2
*Stop Date/Time 8/18/2010 6:03:06 PM 160.00 232.00 3
829,819     
Start Date/Time 8/25/2010 4:14:22 PM 0.00 0.00 1
Stop Date/Time 8/25/2010 4:26:22 PM 12.00 12.00 2
827,519     
*Start Date/Time 8/18/2010 4:05:53 PM 0.00 0.00 1
830,662     
Start Date/Time 8/27/2010 3:52:17 PM 0.00 0.00 1
Stop Date/Time 8/27/2010 5:04:43 PM 72.00 72.00 2
830,721     
Start Date/Time 8/27/2010 5:15:03 PM 0.00 0.00 1
Stop Date/Time 8/27/2010 5:59:21 PM 44.00 44.00 2
*Stop Date/Time 8/27/2010 8:31:39 PM 196.00 240.00 3
831,180     
Start Date/Time 8/30/2010 3:22:09 PM 0.00 0.00 1
Stop Date/Time 8/30/2010 4:16:48 PM 54.00 54.00 2
 
You'll see that I essentially have start and stop times that are manually entered into a database through an interface.  Unfortunately, users don't always remember to enter their start or stop times.  Each record should be a pair.
 
Now, for the most part I've been able to flag the records using a variety of different formulas, but always with the same results.  If the last record in one group (the 6 digit number) is a Start (ie. only one record with no matching stop) and the next groups record begins properly with a 'start', it thinks the record in error is the second one that is starting properly.  Not the one with the missing 'stop' record.

So, essentially I need to flag each record (indicated by the * above) that does not have it's mate.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 13 Apr 2011 at 11:50am

When you're looking for a Stop date, are you using the Next() function?  I assume so.  So, in addition to looking for the stop date, you also need to verify that the 6-digit number on the next record is the same as the one for the existing record.

-Dell
IP IP Logged
mfergel
Newbie
Newbie


Joined: 13 Apr 2011
Online Status: Offline
Posts: 6
Quote mfergel Replybullet Posted: 14 Apr 2011 at 3:19am
That's kind of what I tried and it works to some extent but I've still got records that are missed, for instance when the next record is missing the 'start' and instead starts with a 'stop'.  Also, I think my formula is working to some extent because a start time should always equal zero.
 
Here's what I have so far.
 
If next({Incident.Incident #})<>{Incident.Incident #}
    and {@StartORStop} = "Start Date/Time"
Then green
else
if {@StartORStop} = "Start Date/Time" and previous({@StartORStop}) <> "Stop Date/Time"
or
{@StartORStop} = "Stop Date/Time" and previous({@StartORStop}) <> "Start Date/Time"
then
green
else
white
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 14 Apr 2011 at 4:03am
You need some parentheses  to get this to work correctly.  In your second If statement try this:
 
if ({@StartORStop} = "Start Date/Time" and previous({@StartORStop}) <> "Stop Date/Time")
or
({@StartORStop} = "Stop Date/Time" and previous({@StartORStop}) <> "Start Date/Time" )
 
-Dell
IP IP Logged
mfergel
Newbie
Newbie


Joined: 13 Apr 2011
Online Status: Offline
Posts: 6
Quote mfergel Replybullet Posted: 14 Apr 2011 at 6:42am

Thanks.

This is what I ended up doing in order to resolve the issue.  I actually used it within a manual running total and set the value to zero if it was incorrect.
 
if {@counttest2}=1
and {@StartORStop} = "Start Date/Time"
then White
else
if {@counttest2}=1
and {@StartORStop} = "Stop Date/Time"
then green
else

if   (  {@StartORStop} = "Start Date/Time"
          and next({@StartORStop}) <>  "Stop Date/Time"  )
   or
     (  {@StartORStop} = "Stop Date/Time"
         and previous({@StartORStop}) <> "Start Date/Time" )
then green
else white

IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum