Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
sunitha_chellaiah
Partner - Creator
Partner - Creator

Latest Record Based on Timestamp

Hi,

I need to fetch the latest record from table based on Updated Date and Updated Time field

Note: Needs to do it back end script

ShiftValuesSr. NoUpdated DateUpdated Time
10.43100022-10-201715:44:08
10.36200022-10-201721:10:39
10.48300022-10-201721:10:38
20.43400022-10-201721:13:05
30.43500022-10-201721:12:16
10.12600023-11-201721:12:15
20.12700023-11-201721:12:14
20.13800023-11-201715:05:38
30.12900023-11-201715:05:37

Only latest time should appear against each shift.

output should come as:

ShiftValuesSr. NoUpdated DateUpdated Time
10.36200022-10-201721:10:39
20.43400022-10-201721:13:05
30.43500022-10-201721:12:16
10.12600023-11-201721:12:15
20.12700023-11-201721:12:14
30.12900023-11-201715:05:37
1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD * INLINE [

    Shift, Values, Sr. No, Updated Date, Updated Time

    1, 0.43, 1000, 22-10-2017, 15:44:08

    1, 0.36, 2000, 22-10-2017, 21:10:39

    1, 0.48, 3000, 22-10-2017, 21:10:38

    2, 0.43, 4000, 22-10-2017, 21:13:05

    3, 0.43, 5000, 22-10-2017, 21:12:16

    1, 0.12, 6000, 23-11-2017, 21:12:15

    2, 0.12, 7000, 23-11-2017, 21:12:14

    2, 0.13, 8000, 23-11-2017, 15:05:38

    3, 0.12, 9000, 23-11-2017, 15:05:37

];


Right Join (Table)

LOAD Shift,

[Updated Date],

Max([Updated Time]) as [Updated Time]

Resident Table

Group By Shift, [Updated Date];


Capture.PNG

View solution in original post

2 Replies
sunny_talwar

Try this

Table:

LOAD * INLINE [

    Shift, Values, Sr. No, Updated Date, Updated Time

    1, 0.43, 1000, 22-10-2017, 15:44:08

    1, 0.36, 2000, 22-10-2017, 21:10:39

    1, 0.48, 3000, 22-10-2017, 21:10:38

    2, 0.43, 4000, 22-10-2017, 21:13:05

    3, 0.43, 5000, 22-10-2017, 21:12:16

    1, 0.12, 6000, 23-11-2017, 21:12:15

    2, 0.12, 7000, 23-11-2017, 21:12:14

    2, 0.13, 8000, 23-11-2017, 15:05:38

    3, 0.12, 9000, 23-11-2017, 15:05:37

];


Right Join (Table)

LOAD Shift,

[Updated Date],

Max([Updated Time]) as [Updated Time]

Resident Table

Group By Shift, [Updated Date];


Capture.PNG

sunitha_chellaiah
Partner - Creator
Partner - Creator
Author

Thank you so much!  Sunny