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: 
bartwelvaarts
Contributor III
Contributor III

keep row with min(time)

Hello friends of the qlik community,

 

I have 2 rows, with 2 times. But i only want to keep the row with the earliest time. Can this be accomplished by using set analysis? I attached an example below.

 

thanks in advance!

Labels (2)
1 Reply
morgankejerhag
Partner - Creator III
Partner - Creator III

I can't open the image for some reason, but if you only want to keep the first row in the load script you can either:

Load
   Dim1,
   Dim2,
   timestamp(min(TimeField)) as TimeField // timestamp() or whatever fits
from <source> group by Dim1, Dim2;

This will be a heavy calculation if you have many dimensions (Dim1, Dim2). In this case I would instead read the table using peek() and flag the first row for each key (Lets call it Dim1):

Tmp:
Load
   Dim1,
   Dim2,
   // Many more fields
   if(Dim1<>peek(Dim1),TimeField) as TimeField
from <source> order by Dim1, Timefield asc;

Data:
noconcatenate Load * resident Tmp where not isnull(TimeField);
drop table TimeField;