Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
gauravgg
Partner - Creator
Partner - Creator

Subtract next row with the current row ??

Hi ,

in the following table  where the Status_id = 4 i have to calculate the Result Cloumn by subtracting the update_date_time

highlighted in Orange-  update_date_time in Green in HH:MM:SS

    

id_pkResult Column(HH:MM:SS)Status idupdate_date_time
5632712016-07-26 11:47:36
5632822016-07-26 11:47:59
5633032016-07-26 11:48:30
563312016-07-26 11:49:29 - 2016-07-26 11:48:41=00:00:4842016-07-26 11:48:41
5633242016-07-26 11:49:29
5633432016-07-26 11:51:20
4 Replies
Not applicable

I'd use Peek() in load script. Peek()

gauravgg
Partner - Creator
Partner - Creator
Author

Can u show with example...or share qvf

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Try the below() function. Something like:

if(Status_id=4, below(update_date_time) - update_date_time, '')

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

swuehl
MVP
MVP

You can use Peek(), but Peek() can only address rows already read in, not rows that are located in following records.

You can change the sort order of your table to overcome this:

INPUT:

LOAD id_pk,

     [Result Column(HH:MM:SS)],

     [Status id],

     update_date_time

FROM

[https://community.qlik.com/thread/241212]

(html, codepage is 1252, embedded labels, table is @1);

Result:

LOAD *,

If(Peek('Status id') = 4 and [Status id] = 4,interval(Peek('update_date_time')- update_date_time )) as test

Resident INPUT

order by id_pk desc;

DROP TABLE INPUT;