Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
safik003
Contributor III
Contributor III

Keep only latest record

I have raw data like below...

EmployeeDeptYearMonth
ABanking201812
AFinance201805
AInsurance201808
BBanking201803
BFinance201805

 

But I want to keep the latest data only i.e latest record per employee per Dept per YearMonth like below

EmployeeDeptYearMonth
AInsurance201808
BFinance201805

 

I want to handle this scenario in QlikView script only as there are many transformation. Here is the sample file with above data. Please suggest.

Test:
Load * INLINE
[Employee, Dept, YearMonth
A , Finance, 201805
A , Insurance, 201808
A , Banking, 201812
B , Finance, 201805
B , Banking, 201803];

@sunny_talwar 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

Take a look at the script below, but as you'll notice I where not sure if you wanted the latest transactions per user or latest YearPeriod per user.:

 

Test:
Load rowno() as ID, * INLINE
[Employee, Dept, YearMonth
A        , Finance, 201805
A        , Insurance, 201808
A        , Banking, 201812
B		,  Finance, 201805
B		,  Banking, 201803];

INNER JOIN 
LOAD 
	Employee,
	Max(YearMonth) as YearMonth 	//Use if it is the lates YearMonth per employee
	//Max(ID) as ID  				//Use if it is the latest transaction that ist o be considered per empl.
Resident 
	Test
Group By 
	Employee;

 

.

 

View solution in original post

4 Replies
Vegar
MVP
MVP

Take a look at the script below, but as you'll notice I where not sure if you wanted the latest transactions per user or latest YearPeriod per user.:

 

Test:
Load rowno() as ID, * INLINE
[Employee, Dept, YearMonth
A        , Finance, 201805
A        , Insurance, 201808
A        , Banking, 201812
B		,  Finance, 201805
B		,  Banking, 201803];

INNER JOIN 
LOAD 
	Employee,
	Max(YearMonth) as YearMonth 	//Use if it is the lates YearMonth per employee
	//Max(ID) as ID  				//Use if it is the latest transaction that ist o be considered per empl.
Resident 
	Test
Group By 
	Employee;

 

.

 

AVINASH22
Contributor II
Contributor II

Use aggr function taking expression as Yearmonth with dimension employee
deshikas
Contributor III
Contributor III

See attached

Brett_Bleess
Former Employee
Former Employee

Safikul, did any of the posts help you get a working solution?  If so, please be sure to use the Accept as Solution button on the post(s) that did help you to give the poster credit and let others know which one(s) worked.  If you did something else, consider posting that and mark it the same way, and if you are still working upon things, leave an update.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.