Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

Filter a table based on the first chronological event

Hello,

I have the following table:

EventTable:
Load * inline
[
ID1,    ID2, ID3,  Action,    EventDateTime
10,      1,    99,    Create,    '12/30/2016 11:02'
10,      1,    99,    Update,     '12/30/2016 11:03'
10,     1,     99,   Delete,     '13/30/2016 11:02'
10,      1,    98,   Delete,    '12/30/2016 14:02'
10,      1,    98,   Update,   '12/30/2016 12:02'
10,      2,    99,   Update,   '13/30/2016 13:02'
10,      2,    99,   Update,   '13/30/2016 15:02'
10,      2,    99,   Update,   '12/30/2016 08:02'
];

I would like to keep only one line for a given ID1/ID2/ID3 item i.e. the one with the Min (EventDateTime)

10,      1,    99,   Create,    '12/30/2016 11:02'

10,      1,    98,   Update,   '12/30/2016 12:02'

10,      2,    99,   Update,   '12/30/2016 08:02'

I would very much appreciate your help!

Thanks

Annick

1 Solution

Accepted Solutions
sunny_talwar
Not applicable

Re: Filter a table based on the first chronological event

Try this:

EventTable:

Load * inline

[

ID1,    ID2, ID3,  Action,    EventDateTime

10,      1,    99,    Create,    '12/30/2016 11:02'

10,      1,    99,    Update,    '12/30/2016 11:03'

10,    1,    99,  Delete,    '13/30/2016 11:02'

10,      1,    98,  Delete,    '12/30/2016 14:02'

10,      1,    98,  Update,  '12/30/2016 12:02'

10,      2,    99,  Update,  '13/30/2016 13:02'

10,      2,    99,  Update,  '13/30/2016 15:02'

10,      2,    99,  Update,  '12/30/2016 08:02'

];

Right Join (EventTable)

LOAD ID1,

  ID2,

  ID3,

  Min(EventDateTime) as EventDateTime

Resident EventTable

Group By ID1, ID2, ID3;

5 Replies
sunny_talwar
Not applicable

Re: Filter a table based on the first chronological event

Try this:

EventTable:

Load * inline

[

ID1,    ID2, ID3,  Action,    EventDateTime

10,      1,    99,    Create,    '12/30/2016 11:02'

10,      1,    99,    Update,    '12/30/2016 11:03'

10,    1,    99,  Delete,    '13/30/2016 11:02'

10,      1,    98,  Delete,    '12/30/2016 14:02'

10,      1,    98,  Update,  '12/30/2016 12:02'

10,      2,    99,  Update,  '13/30/2016 13:02'

10,      2,    99,  Update,  '13/30/2016 15:02'

10,      2,    99,  Update,  '12/30/2016 08:02'

];

Right Join (EventTable)

LOAD ID1,

  ID2,

  ID3,

  Min(EventDateTime) as EventDateTime

Resident EventTable

Group By ID1, ID2, ID3;

Not applicable

Re: Filter a table based on the first chronological event

Thanks a lot Sunny for your quick reply!

I tried it, but I might have missed something, as this is the result I get:

For some reason I have lost the EventDateTime and the Action...

Any idea on how to solve this?

Many thanks. Annick

sunny_talwar
Not applicable

Re: Filter a table based on the first chronological event

What is the exact script you used?

Not applicable

Re: Filter a table based on the first chronological event

Hello,

Here's my exact script:

EventTable:
Load * inline
[
ID1,     ID2, ID3,   Action,    EventDateTime
10,      1,   99,    Create,    '12/30/2016 11:02'
10,      1,   99,    Update,    '12/30/2016 11:03'
10,      1,   99,    Delete,    '13/30/2016 11:02'
10,      1,   98,    Delete,    '12/30/2016 14:02'
10,      1,   98,    Update,    '12/30/2016 12:02'
10,      2,   99,    Update,    '13/30/2016 13:02'
10,      2,   99,    Update,    '13/30/2016 15:02'
10,      2,   99,    Update,    '12/30/2016 08:02'
];


Right Join (EventTable)
LOAD ID1,
     ID2,
     ID3,
     Min(EventDateTime) as EventDateTime
Resident EventTable
Group By ID1, ID2, ID3;

Thanks a lot!

Annick

Not applicable

Re: Filter a table based on the first chronological event

Hi Sunny,

Sorry, please ignore my last question. Your initial reply is correct and works fine (The issue I encountered was due to the format of the date). Many thanks for your help. Annick