Skip to main content
Announcements
Announcing Qlik Talend® Cloud and Qlik Answers™ to accelerate AI adoption! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to compare each value of a table to its successor?

Hello community.

I have a list of timestamps like this:

2014-02-25_09h23_19.jpg

I am trying to compare each timestamp to the following one. The goal is to identify a block of timestamps where the max time between 2 stamps is smaller then 5 minutes.

From experience with regular coding languages I would think of something like a "FOR" construction or a loop. But since I am new to Qlik I could not figure out the desired functionality yet.

The sescond question is, how do I adress a certain value from a table? When I am comparing values I want to get a timestamp X and its following stamp X+1.

thanks in advance for your suggestions

regards,

Christian

2 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Invert the sorting order of your table (LOAD with ORDER DESC), and compare to the previous one using a function called... previous(). Previous() will look to the field content in the previous row of the input table (the one mentioned after RESIDENT).

Peter

Not applicable
Author

Christian,

May I suggest you to read the doc I have written on LOAD (script) topic:

http://community.qlik.com/docs/DOC-5698

Chapter 3.4 shows you how to reuse info from prevous line (therefore, sort your table so that the previous line is the one you expect to have). You cannot directly address a line that has not been loaded yet.

You can therefore create a flag (1, 0) on the Line N if the time elapsed is more than 5 minutes.

Afterwards, you can load a new table by inverting the order (the last line becomes the first) and test if the flag of the previous line (therefore the next period because you have inverted the order) was 1 or 0. And flag the current ine.

Fabrice