Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
My input data are timestamped logs of events. Many have an on/off status change as property.
There are around 500 different types of events from multiple objects in the log.
I have tried to understand the multiple load options in qlik but am finally rather confused.
Any suggestion how to create a duration table in addition to the event table which would give me the
object, event and the event status on and off timestamps as a event duration record?
Or would you recommend to use another tool to create such a duration list externally (like awk or logparser)
Thanks
Jürg
If you load the data ordered by event type and timestamp, you should be able to calculate the differences in the load script. I believe the code should look like
Input_raw:
LOAD
event_type,
tstamp
FROM
whatever_datasource;
Input_ordered:
LOAD
event_type,
tstamp
RESIDENT
Input_raw
ORDER BY
event_type,
tstamp;
Input_tdiff:
LOAD
*,
if( event_type = previous( event_type ), tstamp - previous( tstamp ), null() ) AS tdiff
RESIDENT
Input_ordered;
DROP TABLES Input_raw, Input_ordered;
Hope this helps,
Hellmar
If you load the data ordered by event type and timestamp, you should be able to calculate the differences in the load script. I believe the code should look like
Input_raw:
LOAD
event_type,
tstamp
FROM
whatever_datasource;
Input_ordered:
LOAD
event_type,
tstamp
RESIDENT
Input_raw
ORDER BY
event_type,
tstamp;
Input_tdiff:
LOAD
*,
if( event_type = previous( event_type ), tstamp - previous( tstamp ), null() ) AS tdiff
RESIDENT
Input_ordered;
DROP TABLES Input_raw, Input_ordered;
Hope this helps,
Hellmar
Thanks Hellmar, I have tried to implement with my data and results look promising. I will try to start handling of missing and duplicate on/off events.
Jürg
Hi,
i noticed that you should sort your time table the other way around...
Here's why:
If you would like to calculate the time an item has been in a specific status, you should:
Or in code:
load
*,
if(item=previous(item),interval((previous(TimeStamp)-TimeStamp),'dd'),now()-TimeStamp) as StatusDurationInDays
Resident StatusTable
Order by item,TimeStamp desc;
Herbert