Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Prakhar1
Creator III
Creator III

Assigning previous row id to next row

Hi,

I have a table like

item_id,item_name

1,a

1,b

1,c

2,x

2,y

2,z

Now, I want the output to be like: 

surr_key, item_id,item_name, parent_id

1,1,a,-1

2,1,b,1

3,1,c,2

4,2,x,-1

5,2,y,4

6,2,z,5

Here, surr_key is auto_increment and parent_id is the surr_key of precious row for the same item_id.

a is the first item for item_id=1 thus it will be -1 and same with x.

Can anyone help how to achieve it ?

Labels (3)
3 Replies
Anonymous
Not applicable

This post answers a slightly different question, but you can use the method to do what you want. Essentially you are looking at the functionality which means that tMap variables are actioned in order from top to bottom and they preserve their values between rows.

 

https://community.talend.com/t5/How-Tos-and-Best-Practices/Compare-row-value-against-a-value-from-th...

Prakhar1
Creator III
Creator III
Author

how to do this with integer values, as the compareignorecase accepts string values only
Anonymous
Not applicable

You can use compareTo()  for Integers or == for primitive type ints