Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ciaran_mcgowan
Partner - Creator III
Partner - Creator III

Loop through table to find first value

Hi all,
I have an issue where I have to find the first ID of a row in a table for each row. Every row contains an ID, but it also has the ID of that row's predecessor and there is no limit to how many predecessors a row can have. See example below:
IDNamePrevious IDComplete
1Person 1No
2Person 21No
3Person 3No
4Person 43Yes
5Person 52No
6Person 65Yes

I need to add a column called Original ID which will look like below. Any thoughts?

IDNamePrevious IDCompleteOriginal ID
1Person 1No1
2Person 21No1
3Person 3No3
4Person 43Yes3
5Person 52No1
6Person 65Yes1
1 Solution

Accepted Solutions
rahulpawarb
Specialist III
Specialist III

This can be achieved using Hierarchy function. Please refer attached sample application.

Regards!

Rahul Pawar

View solution in original post

6 Replies
Anil_Babu_Samineni

What was the logic behind? that may helps you

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Chanty4u
MVP
MVP

how the original id column defined from?  what is the caluclation ?

ciaran_mcgowan
Partner - Creator III
Partner - Creator III
Author

I don't have access to the logic but it looks to be incremental rows. No set order or logic that I can use to link. I'm thinking that this is going to require multiple FOR loops.

rahulpawarb
Specialist III
Specialist III

This can be achieved using Hierarchy function. Please refer attached sample application.

Regards!

Rahul Pawar

ciaran_mcgowan
Partner - Creator III
Partner - Creator III
Author

I created a hierarchy and joined it to my table using the ID fields and brought in the new field which was the top position from the hierarchy.

Thanks!

rahulpawarb
Specialist III
Specialist III

Cheers!

Rahul Pawar