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: 
Jakovic93
Contributor
Contributor

Want to get second oldest date for each ID

Hello Guys,

i am very new in QlikCloud and need your help:

I have the following table:

ID Date
A 26.05.2023 14:25
B 28.05.2023 10:20
A 20.01.2023 10:52
B 22.06.2023 10:21
A 10.05.2023 09:45
C 01.05.2023 08:25
B

22.04.2023 15:20

C

28.05.2023 16:20

C

10.06.2023 14:20

 

I want to get the second oldest date for each ID. Old in this context means that the date is more in the past. I don't want to get the oldest date, which is easily extracted be min function and group by.

The result should be the folllowing:

ID Date
A 10.05.2023 09:45
B 28.05.2023 10:20
C 28.05.2023 16:20

 

What it the corresponding Code for this Problem?

Thanks a lot for your help!

Labels (2)
1 Reply
BrunPierre
Partner - Master
Partner - Master

Hi, Do this.

Temp:
LOAD ID,
Timestamp(Timestamp#(Date, 'DD.MM.YYYY hh:mm), 'DD.MM.YYYY hh:mm) as Date
FROM <Source Table> ;

NoConcatenate
Final:
LOAD ID,
FirstSortedValue(Date, Date, 2) as Date

Resident Table
Group By ID;

DROP Table Temp;

EXIT SCRIPT;