Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Removing duplicates, getting latest value via multiple criteria

Hi there,

I have a set of data like this

            

Product NoDate CreatedRecord NoDate AlteredReason
14/8/2014RN00014/6/2014Damaged
14/8/2014RN00254/6/2014AutoRepaired
14/1/2015RN90904/11/2014Damaged
25/9/2015RN00023/9/2015Creation
36/8/2015RN00036/7/2015Damaged
36/8/2015RN00046/7/2015AutoRepaired
310/10/2015RN00069/9/2015Damaged

I would like to remove duplicated based on product no, and get the latest value. Which should look like this

(This is to be done in load script)

Product NoDate CreatedRecord NoDate AlteredReason
14/1/2015RN90904/11/2014Damaged
25/9/2015RN00023/9/2015Creation
310/10/2015RN00069/9/2015Damaged

Basically for each product no, i would like to obtain the data that has the LATEST DateCreated,RecordNo,DateAltered.

Thank you.

32 Replies
Not applicable
Author

Hi sunnyT,

thank you for your prompt reply.

I found the problem.

My date created field is recognized as a string which i am not sure how sort is working it out.

My solution was during load,

Date#(datecreated,'DD/MM/YYYY') as datecreated

then it solves the issue.

One small question,

for order by asc or desc, do they sort by numerical or A to Z? or is it possible to specify?

because in this case, my datecreated field is not recognized as a date, thats why i have this problem.

Thank you.

sunny_talwar

Not sure I understand your question, but numericals and strings can both be sorted

Asc

Numerical -> 1, 2, 3, 4....

String ->  A, B, C, D

Desc

Numerica -> 4,3,2,1...

String -> Z, Y, X, ....

was that your question?

Not applicable
Author

So basically, if i dont do Date#(datecreated,'DD/MM/YYYY') as datecreated when loading the table, my datecreated will not be sorted according to my order by. Only after doing that, i can sort it according to what i want.

If say a field, is not specified to be a date field or string, and i put say 21/11/2015, it will align to left side of the field (assuming you open a tablebox or straight table, regardless.)

And it will not sort correctly.

Only after doing Date#(datecreated,'DD/MM/YYYY') as datecreated, then would it sort correctly.

Why is this so?