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

How to pick up the second date from the data

Hi,

I have data like this

TicketTaskCreated DateLast modified DateCreated By
111-Jan-2017 10:001-Jan-2017 10:15Admin
121-Jan-2017 12:001-Jan-2017 12:05Agent
13 2-Jan-2017 10:052-Jan-2017 10:06Agent
241-Jan-2017 11:001-Jan-2017 11:15Admin
251-Jan-2017 13:001:Jan-2017 13:05Agent
26 2-Jan-2017 10:052-Jan-2017 10:06Agent
372-Jan-2017 10:052-Jan-2017 10:05Admin
382-Jan-2017 10:052-Jan-2017 10:05Agent

Here the data is grouped by Ticket, i have to pick the start date and end date from this data.

Start date will be the Created Date (which is created by Admin)

For example, Ticket = 1, the Start Date is 1-Jan-2017 10:00 (Task created by Admin)

End date will be the Last Modified Date (The Last modified date after the first task (Admin task) should be considered).

For example, Ticket = 1, The end date is 1-Jan-2017 12:05.

My question is, How to pick up the last modified date from the date which is the task created (Task after the admin task, i.e., task created by some agent) after the first task (Which is created by admin)

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this,

Data:

Load Ticket,Min(CreatedDate) as MinDate

From xyz

Where Createdby='Admin'

Group by Ticket;

Left join

Load Ticket,Max(LastModifiedDate) as MaxDate

From xyz

Where Createdby<>'Admin'

Group by Ticket;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
udaya_kumar
Specialist
Specialist
Author

Hi,

If i use the below code, then it will take the last row date in the last modified date field group by Ticket right,

But i want the row after the admin task date to be picked up in the script.

Left join

Load Ticket,Max(LastModifiedDate) as MaxDate

From xyz

Where Createdby<>'Admin'

Group by Ticket;

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Thats fine,

In such case you can use the Min function, which will take the immediate next row after Admin row.

Left join

Load Ticket,Min(LastModifiedDate) as NextDate

From xyz

Where Createdby<>'Admin'

Group by Ticket;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!