Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate duration over multiple rows with specific values

I have a table with multiple actions. Each action has an action type.

ParticipantEventUserAction_TypeDate/Time
1557332112014-05-26 13:30:12.000
1557332122014-05-26 13:31:00.000
1358651112014-05-26 13:31:33.000
1557332132014-05-26 13:32:00.000
1685332312014-05-26 13:34:00.000
1557332142014-05-26 13:36:00.000
1358651122014-05-26 13:38:00.000
1557332152014-05-26 13:39:00.000

I want to calculate the duration from each event per participant per event per user. the start is Action_Type 2 and the end is Action_Type 4

So with this table i want to know that the duration of event "332" from participant "1557" and User "1" is 13:36:00.000 - 13:31:00.000 = 0:05:00.000

How can i do that? Thanks for any help you can give!

4 Replies
Not applicable
Author

The thing i want to do with the result is showing a chart with all the events under 15 min and all events under 30 min and so on.

Gysbert_Wassenaar

See attached example


talk is cheap, supply exceeds demand
Not applicable
Author

Hi.

Try use this:

Events:

LOAD * INLINE [

    Participant, Event, User, Action_Type, Date/Time

  1557,332,1,1,2014-05-26 13:30:12.000

  1358,651,1,1,2014-05-26 13:31:33.000

  1685,332,3,1,2014-05-26 13:34:00.000

  1557,332,1,2,2014-05-26 13:31:00.000

  1358,651,1,2,2014-05-26 13:38:00.000

  1557,332,1,3,2014-05-26 13:32:00.000

  1557,332,1,4,2014-05-26 13:36:00.000

  1557,332,1,5,2014-05-26 13:39:00.000

];

tempComplitedEvents:

LOAD Participant,

  Event,

  User,

  [Date/Time] as Start

Resident Events Where Action_Type=2;

Inner Join

LOAD Participant,

  Event,

  User,

  [Date/Time] as End

Resident Events Where Action_Type=4;

DROP Table Events;

ComplitedEvents:

LOAD Participant,

  Event,

  User,

  Time(End -Start) as Duration

Resident tempComplitedEvents;

DROP Table tempComplitedEvents;

MarcoWedel

Hi Tom,

another one:

QlikCommunity_Thread_119762_Pic4.JPG.jpg

QlikCommunity_Thread_119762_Pic5.JPG.jpg

QlikCommunity_Thread_119762_Pic6.JPG.jpg

=Dual(Interval(SubField(Class(Duration, '00:15:00'),'<=', 1),'hh:mm:ss')&' - '&Interval(SubField(Class(Duration, '00:15:00'),'<', 3),'hh:mm:ss'), Duration)

QlikCommunity_Thread_119762_Pic1.JPG.jpg

tabEvents:

LOAD

  AutoNumberHash128(Participant, Event, User) as %EventID,

  *

FROM [http://community.qlik.com/thread/119762] (html, codepage is 1252, embedded labels, table is @1);

tabDateTimes:

Generic LOAD

  %EventID,

  'DateTimeActTyp'&Action_Type,

  [Date/Time]

Resident tabEvents;

hope this helps

regards

Marco