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!

Subtract previous minimum time from current minimum time

Status
Not open for further replies.

capronton

MIS
Jun 28, 2013
159
0
0
US
I'm using the formula below to calculate "actHdwy". However the formula places the "actHdwy" next to wrong vehicle.
For example, vehicle 5005 does not have "actHdwy" of 11 minutes, bus 5007 should be 11 minutes.
Vehicle 5017 should be 19 minutes, vehicle 5008 should be 11 minutes, 5013 should 16 minutes, etc.,

In other words, how can I modify the formula below to shift the "actHdwy" down to the correct vehicle?
Thanks for any assistance.

WhilePrintingRecords; //Place in Group Footer
if {command.vehicle_id} <> Next({command.vehicle_id}) then
(
Time(next({command.incident_date_time})) -
Time(Minimum ({command.incident_date_time}, {command.vehicle_id}))
)/60
else 0;

incDate sched_time actHdwy vehicle_id
5:10:54 AM 5:07 AM 0 5005
5:13:54 AM 5:07 AM 0 5005
5:15:54 AM 5:07 AM 11 5005

5:21:54 AM 5:22 AM 19 5007

5:40:54 AM 5:37 AM 11 5017

5:51:56 AM 5:52 AM 16 5008

6:07:55 AM 6:07 AM 18 5013

6:25:56 AM 6:22 AM 5 5020

6:30:55 AM 6:34 AM 0 5021
6:40:55 AM 6:34 AM 17 5021

6:47:55 AM 6:49 AM 16 5011

7:03:55 AM 7:04 AM 13 5015

7:16:56 AM 7:16 AM 12 5002

7:28:56 AM 7:28 AM 0 5006
7:30:56 AM 7:28 AM 13 5006

7:41:56 AM 7:40 AM 9 5019

7:50:56 AM 7:52 AM 12 5066

8:02:56 AM 8:04 AM 0 5014
8:04:56 AM 8:04 AM 0 5014
8:06:56 AM 8:04 AM 11 5014

8:13:56 AM 8:16 AM 12 5022

8:25:56 AM 8:28 AM 0 5012
8:26:56 AM 8:28 AM 0 5012
8:27:56 AM 8:28 AM 0 5012
8:31:56 AM 8:28 AM 21 5012

8:46:57 AM 8:42 AM 9 5005
 
If you want it on the next line, change your logic from using Next to using Previous.
 
I'm trying to subtract previous minimum time from current minimum time, but I get an error.
Can someone explain?

WhilePrintingRecords; //Place in Group Footer
if {command.vehicle_id} <> previous({command.vehicle_id}) then
(
Time(Minimum ({command.incident_date_time}, {command.vehicle_id})) -
Time(previous(Minimum ({command.incident_date_time}, {command.vehicle_id})))
)/60
else 0;
 
The Error is "This field has no previous value"

(previous(Minimum ({command.incident_date_time}, {command.vehicle_id})))

Is it possible to get the previous minimum incident_date_time?

Or is there another way to subtract previous minimum time from current minimum time?
 
Add this to the beginning of your formula: Not(onfirstrecord) and .... the rest of your formula.....
 
Just noticed your response Charliy. Thanks.

I think it's going to work the way it is currently set up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top