Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
cpalbrecht
Creator
Creator

Peek value of next row within a group

I have a table like this:

DateKey
Date1A
Date2B
Date3A
Date4A
Date5B
Date6B
Date7B
Date8A
......

The result should look like:

DateKeyDiff
Date1A
Date2B
Date3ADate3-Date1
Date4ADate4-Date3
Date5BDate5-Date2
Date6BDate6-Date5
Date7BDate7-Date6
Date8ADate8-Date4
.........

I can't solve the problem with peek, group by and sort by.

Can anyone help me here?

Thanks!

1 Solution

Accepted Solutions
cpalbrecht
Creator
Creator
Author

2 Replies
cpalbrecht
Creator
Creator
Author

Ok, I found the solution here: https://community.qlik.com/thread/180199

Anonymous
Not applicable

TEMP:
LOAD RecNo() as ##,* INLINE [
DATEFIELD, FIELD
Date1, A
Date2, B
Date3, A
Date4, A
Date5, B
Date6, B
Date7, B
Date8, A
]
;
TEMP2:
LOAD RecNo() as ##_2,
if(FIELD=Previous(FIELD),(DATEFIELD&'-'&Previous(DATEFIELD))) as NEWDATEFIELD,
*
Resident TEMP
order by FIELD,DATEFIELD;

NoConcatenate

TABLE:
LOAD * Resident TEMP2
order by ##;

DROP Table TEMP,TEMP2;
DROP Field ##_2,DATEFIELD;
RENAME field NEWDATEFIELD to DATEFIELD;