Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
cicciput
Contributor III
Contributor III

Limit load to X records per group

I have a huge login table, with all the login times of all users since ages.

How do I limit load to last, say, 10 logins per user so I can have a glimpse on their habits without the burden?

Something like:

LOAD Only(UserID),

     FirstValues(LoginDate, 10)

GROUP BY UserID

ORDER BY LoginDate DESC;


I tried searching for an answer with no luck.


Thanks for your help

15 Replies
cicciput
Contributor III
Contributor III
Author

Thank you for your answer, I accepted Antonio's answer below as it does not leave an extra column in Login table.

cicciput
Contributor III
Contributor III
Author

Hello Tomasz,

this won't happen as soon as I declare Login: as a new table with it's own name, just tested I get the reults

cicciput
Contributor III
Contributor III
Author

hello Antonio,

I marked this as correct as a proof of concept.

In reality this keeps the first 2 logins while I asked for the last 2.

For this reason more work is expected instead of a simple "WHERE A>=2",

however you set me in the right direction, thank you.

antoniotiman
Master III
Master III

Hi Renzo,

use above script with NoConcatenate and AutoNumber(RowNo(), UserID) <= 2

First or Last is depending on Desc or Asc in Order By  clause.

Regards,

Antonio

cicciput
Contributor III
Contributor III
Author

Hello Antonio,

you are right, noconcatenate included.

I updated correct answer, thank you for your help

antoniotiman
Master III
Master III

I'm glad to helped You.

Regards,

Antonio