Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

getting latest record in script

Hi All,

i am trying to create a flag for the latest record in the script;

I have an email address and Date, i want to flag the row with the latest date per email address.

i have attached an example, my real data has a lot more fields but Email is the key to the rest of the tables and its the date i need it sorted on.

can anyone help please?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

Data:

Load * inline [

Email, Date

PersonA@Email.com, 01/01/2012

PersonA@Email.com, 01/02/2012

PersonA@Email.com, 01/05/2012

PersonA@Email.com, 01/09/2012

PersonB@Email.com, 01/01/2013

PersonB@Email.com, 01/08/2015

PersonB@Email.com, 01/04/2016

]

;

LEFT JOIN

LOAD Email, Maxstring(Date) as Date, 1 as Flag

RESIDENT Data

GROUP by Email;

View solution in original post

3 Replies
swuehl
MVP
MVP

Maybe like

Data:

Load * inline [

Email, Date

PersonA@Email.com, 01/01/2012

PersonA@Email.com, 01/02/2012

PersonA@Email.com, 01/05/2012

PersonA@Email.com, 01/09/2012

PersonB@Email.com, 01/01/2013

PersonB@Email.com, 01/08/2015

PersonB@Email.com, 01/04/2016

]

;

LEFT JOIN

LOAD Email, Maxstring(Date) as Date, 1 as Flag

RESIDENT Data

GROUP by Email;

jonathandienst
Partner - Champion III
Partner - Champion III

Data:

Load * inline [

Email, Date

PersonA@Email.com, 01/01/2012

PersonA@Email.com, 01/02/2012

PersonA@Email.com, 01/05/2012

PersonA@Email.com, 01/09/2012

PersonB@Email.com, 01/01/2013

PersonB@Email.com, 01/08/2015

PersonB@Email.com, 01/04/2016

]

;

Join (Data)

LOAD Email,

  Max(Date) as Date,

  1 as MaxFlag

Resident Data

Group By Email

;

Capture.PNG

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Thanks Stefan, i didn't think of doing something as simple as that, i have been trying to get it working using FirstSortedValue or applymap!

thanks!