Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Difference Between Time Rows

Hi All,

Below is part of a table in my data model.  I want to get the difference between each start/finish time in order (Row 2- Row 1, Row 4-Row3, etc...) 2:22:59 AM - 2:15:28 AM = X.  I have tried several variations of set analysis to no avail.  Please help!

Capture REL.PNG

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Test:

Load

  Type,

  Time(Time#(Time,'h:m:ss TT')) as Time,

  Record

Inline

[

  Type, Time, Record

  Start, 2:15:28 AM, 1

  Finish, 2:22:59 AM, 2

  Start, 3:15:28 AM, 3

  Finish, 3:22:56 AM, 4

  Start, 4:15:28 AM, 5

  Finish, 4:23:00 AM, 6

  Start, 5:15:28 AM, 7

  Finish, 5:22:57 AM, 8

  Start, 6:00:22 AM, 9

  Finish, 6:00:43 AM, 10

];

Final:

Load

  Type,

  Time,

  If(Type = 'Finish',Interval(Time-Previous(Time)),0) as Difference,

  Record

Resident Test

Order By Record;

Drop Table Test;

View solution in original post

4 Replies
MK_QSL
MVP
MVP

Easiest way is to calculate script level. Provide sample data in excel.. will do it for you..

Not applicable
Author

Hi Manish,

Thanks you. See attached for sample data.

MK_QSL
MVP
MVP

Test:

Load

  Type,

  Time(Time#(Time,'h:m:ss TT')) as Time,

  Record

Inline

[

  Type, Time, Record

  Start, 2:15:28 AM, 1

  Finish, 2:22:59 AM, 2

  Start, 3:15:28 AM, 3

  Finish, 3:22:56 AM, 4

  Start, 4:15:28 AM, 5

  Finish, 4:23:00 AM, 6

  Start, 5:15:28 AM, 7

  Finish, 5:22:57 AM, 8

  Start, 6:00:22 AM, 9

  Finish, 6:00:43 AM, 10

];

Final:

Load

  Type,

  Time,

  If(Type = 'Finish',Interval(Time-Previous(Time)),0) as Difference,

  Record

Resident Test

Order By Record;

Drop Table Test;

Not applicable
Author

Perfect, thank you, Manish.