Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikwiz123
Creator III
Creator III

Max Record for Max Date

 

I have the sample data as below.

AgeA.DateB.DateUnique ID
12019-02-01 12:02:232/20/2019ABC55
22019-02-04 12:01:482/20/2019ABC55
32019-02-05 12:02:122/20/2019ABC55
42019-02-06 12:01:452/20/2019ABC55
52019-02-07 12:02:002/20/2019ABC55
62019-02-08 12:02:262/20/2019ABC55
72019-02-11 12:01:542/20/2019ABC55

 

I need to create a new field in the script where it contains the Age for the maximum A.Date column.

For ABC55, the New Age field should contain 7 since the Maximum A.Date Timestamp is 2019-02-11 12:01:54

Labels (1)
4 Replies
tincholiver
Creator III
Creator III

Table:
LOAD * Inline
[Age, A.Date, B.Date, Unique ID
1, 2019-02-01, 12:02:23, 2/20/2019, ABC55
2, 2019-02-04, 12:01:48, 2/20/2019, ABC55
3, 2019-02-05, 12:02:12, 2/20/2019, ABC55
4, 2019-02-06, 12:01:45, 2/20/2019, ABC55
5, 2019-02-07, 12:02:00, 2/20/2019, ABC55
6, 2019-02-08, 12:02:26, 2/20/2019, ABC55
7, 2019-02-11, 12:01:54, 2/20/2019, ABC55
];

Left Join
Temp_Date:
LOAD
[Unique ID],
max(A.Date) as Max_Date
Resident Table Group by [Unique ID];
qlikwiz123
Creator III
Creator III
Author

I need to create a New Age field for the Maximum A.Date column and this one only adds Max(A.Date) to the existing table

vishsaggi
Champion III
Champion III

Try this?

T1:
LOAD Age,
A.Date,
B.Date,
[Unique ID]
FROM
[https://community.qlik.com/t5/New-to-QlikView/Max-Record-for-Max-Date/m-p/1547024#M370379]
(html, utf8, embedded labels, table is @1);

Left Join(T1)
LOAD [Unique ID],
Date(Max(A.Date)) AS MaxDate
Resident T1
Group By [Unique ID];

Left Join(T1)
T2:
LOAD Age AS NewAge
Resident T1
WHERE A.Date = MaxDate;
andrescc
Contributor III
Contributor III

Hi,
Try this:

Table:
LOAD * Inline
[Age, A.Date, B.Date, Unique ID
1, 2019-02-01, 12:02:23, 2/20/2019, ABC55
2, 2019-02-04, 12:01:48, 2/20/2019, ABC55
3, 2019-02-05, 12:02:12, 2/20/2019, ABC55
4, 2019-02-06, 12:01:45, 2/20/2019, ABC55
5, 2019-02-07, 12:02:00, 2/20/2019, ABC55
6, 2019-02-08, 12:02:26, 2/20/2019, ABC55
7, 2019-02-11, 12:01:54, 2/20/2019, ABC55
];

Left Join
Temp_Date:
LOAD
[Unique ID],
LastValue(Age) as New_field_age
Resident Table
Group by [Unique ID]
Order By A.Date asc;

Regards,
ACC