cancel
Showing results for 
Search instead for 
Did you mean: 

Running Time Difference/Deltas Time

Ben_R
New Contributor
For table ([]X:`a`a`b`b`b; Time: 10:30:00.123 11:35:00.123 09:30:00.123 10:30:12.123 13:30:00.123)

How can I calculate a new table that has the differences by X?

result:  ([]Y:`a`b`b;Diff: 05:00:00 01:00:12.001 03:00:00.002)

thx.
2 REPLIES 2

jwbuitenhuis
New Contributor

Hi Ben,


Is this a step in the right direction?


value select Y:1_X, Diff:1_ deltas Time by X from t


deltas gives the differences

1_  gets rid of the startup value

value gets rid of the table key


Will



Himanshu
New Contributor II
This might be what you are looking for:

Given:

a: ([]X:`a`a`b`b`b; Time: 10:30:00.123 11:35:00.123 09:30:00.123 10:30:12.123 13:30:00.123)

Result:

ungroup select Diff:1_ deltas Time by X from a

As JW Buitenhuis mentioned, deltas gives you difference between consecutive rows and you can group the response using 'by'. 1_ removes the first entry if you don't want that per group. This gives you back a dictionary. Ungroup...well, ungroups the data and returns a table in the format you asked for.

- Himanshu Gupta | www.enlistq.com