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: 
richters
Partner - Contributor III
Partner - Contributor III

How to get last row having the same ID

Hi all,

until now I could always get the last record by using peek(...,-1) or previous(). But now I need the last record where my field 'EbeneID' is the same. So I load data like this (just ignore the text is always the same, just for showing issues):

IDEbeneIDText
11some Text
22some Text
33some Text
42some Text
51some Text
62some Text
73some Text
81some Text

Now I want to get the text of the previous record with the same EbeneID without order the table by EbeneID (in real the table is much bigger, and it is not really an ID, its all about HTML-Code, so it is not possible to order the table and get the right text each!)

I need something like:
previous(text where previous(EbeneID) = EbeneID) , sure this doesn't work

Thanks in advance!

15 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

That gives the solution to his output table as given, but unfortunately the actual required output is the table in my subsequent post.

Good point about script vs UI though - richters, does the solution need to be based on user-selections?

richters
Partner - Contributor III
Partner - Contributor III
Author

No,

this has to be in the loading script because this is just the basis of further work in the script.

nstefaniuk
Creator III
Creator III

Oh in that case it's really easy, just use FirstSortedValue combined with a filter (with If clause) to get the max-ID-with-same-EbeneID-but-inferior-to-current-ID

nstefaniuk
Creator III
Creator III

Here it is

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Nice

richters
Partner - Contributor III
Partner - Contributor III
Author

Well done, thank you. I have to look at it in detail later on. Thanks!