Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
jim_chan
Contributor III

loading script - how to pick name based on lastest creation date and create as a field?

Hi guys, 

i have a question, and i do not know how to achieve it in loading script. i have created a sample qvw. and a screenshot.

My request:

user would like to create a new field - product_id & name(based on latest create_date).  user wants the productID concantenate with a name of last creation date. 

screenshot1.jpg

Rgds

Jim

4 Replies
passionate
Valued Contributor

Re: loading script - how to pick name based on lastest creation date and create as a field?

Just use
Product_id&name as Productidlastname
In load script
passionate
Valued Contributor

Re: loading script - how to pick name based on lastest creation date and create as a field?

If you have multiple date entry then.

Load Productid,
Name,
Creationdate,
Productid &Name as Productidlastname;
Load
Productid,
Name,
Max(creationdate) as creationdate
Resident table
Group by name, productid;
MVP
MVP

Re: loading script - how to pick name based on lastest creation date and create as a field?

First change the date format at the top of your script so that your dates are properly recognised:

SET DateFormat='D/M/YYYY';
SET TimestampFormat='D/M/YYYY h:mm:ss[.fff] TT';

Then add this after the inline load:

Join(table1)
LOAD product_id,
	product_id & FirstSortedValue(name, -create_date) as newField
Resident table1
Group By product_id;

 

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jim_chan
Contributor III

Re: loading script - how to pick name based on lastest creation date and create as a field?

Dear Jon, 

 

YES!! Thanks! i didnt know firstsortedvalue can be used at the back, most of the time, i used it at front end set analysis!

 

Thanks again!

 

Rgds

 

Jim