Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
Showing results for 
Search instead for 
Did you mean: 
Creator II
Creator II

Retrieve the last 5 records in a table

Dear Qlikview user


I was wondering if someone could kindly help me with a potential way forward 

I am using example data but the concept is real. I would like to retrieve the last 3 records for each patient in a  load script table i



Patient Number     Date                       Test

123                               01/01/2020          1

123                               02/01/2020           1

123                               03/01/2020            1

123                                04/01/2020            1

123                                05/02/2020            1




The records I would like to be returned are highlighted in bold.    Before I go down a rabbit warren of possibilities I.e. using the peek function, loop functions etc, I was wondering if there is a function built in which I could use to retrieve the last 3 records per patient 

If you have come across something similar in the past, a helpful hint would be gratefully appreciated


Kind Regards







3 Replies
Creator II
Creator II

Hi try my attached solution to see if that works. Thanks!

Creator II
Creator II

Thank you for taking the time to reply


We are testing it now and will get back to you as to whether the solution worked


kind Regards





Helen, just a gentle reminder to not forget to return to your thread and close things out...  I am guessing the sample app likely worked, if so, please be sure to use the Accept as Solution button on that post to mark it as the solution, which will give credit to the poster for the help and let the other Members know it worked.  If you still need further help, please leave an update.


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.