cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
MK1985
Level I

How to convert timestamp data to duration time for each batch using jsl script

Hi all,

 

I have started using JSL and is currently on a beginner level.

My data consists of time-series batch data for different process variables. Each batch has a different time series range/ processing time. Data resolution is 1 hr.

MK1985_0-1608641051958.png

 

 

First, I want to convert the batch start time (Real-time) into duration time starting at time point zero (0) and then accumulate to the end Real-time. I think I manage to do that using a script that I found online. However, this only works for the first batch.

For the second batch, the Real-time conversion into duration time does not start at time point zero.

Question: How can I make/modify the script, so it takes into consideration for each batch ID and the respective processing time?              

 

Thanks in advance

 

SCRIPT

names default to here (1);
dt = current data table ();
dt << New Column( "Duration",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() == 1, 0, :TimeStamp - :TimeStamp[1] ) / 60


)
);
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How to convert timestamp data to duration time for each batch using jsl script

Here is the simple script that creates a new column with a formula that calculates the duration from the beginning of each batch

batch.PNG

names default to here( 1 );
dt = Current Data Table();
dt << New Column( "Duration",
	Format( ":day:hr:m:s", 21, 3 ),
	formula(
		If( Row() == 1 | :Batch != Lag( :Batch ),
			start = :Timestamp
		);
		:Timestamp - start;
	)
);
Jim

View solution in original post

Re: How to convert timestamp data to duration time for each batch using jsl script

This alternative uses a built-in function, Col Minimum( x, group ).

 

Screen Shot 2020-12-22 at 12.33.16 PM.png

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to convert timestamp data to duration time for each batch using jsl script

Here is the simple script that creates a new column with a formula that calculates the duration from the beginning of each batch

batch.PNG

names default to here( 1 );
dt = Current Data Table();
dt << New Column( "Duration",
	Format( ":day:hr:m:s", 21, 3 ),
	formula(
		If( Row() == 1 | :Batch != Lag( :Batch ),
			start = :Timestamp
		);
		:Timestamp - start;
	)
);
Jim

Re: How to convert timestamp data to duration time for each batch using jsl script

This alternative uses a built-in function, Col Minimum( x, group ).

 

Screen Shot 2020-12-22 at 12.33.16 PM.png

MK1985
Level I

Re: How to convert timestamp data to duration time for each batch using jsl script

Thanks a lot Mark. It is working very well. Merry Christmas