Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
ant2
Contributor
Contributor

Approach to looping through and comparing data

Hello.

Lets say I have Table A:

 

Table A

- Id

- EnterDate

- StaffNum

- Site

 

I need to find:

 

Query 1. All rows from Table A where Site = 'North'

Query 2. For each row returned in Query 1, I then need to find any rows in Table A where the StaffNum is equal, Site = 'South' and EnterDate is greater than the EnterDate returned in Query 1.

Lost on this one, any advice on starter code would be greatly appreciated.

 

Thanks.

 

Labels (1)
2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

"For each row returned in Query 1,"

Should the Query 2 then match first on id field?

-Rob

ant2
Contributor
Contributor
Author

Hi Rob

 

Thanks for the reply.

 

Query 2 should first match StaffNum, e.g. if Query 1 returned a row where StaffNum was 12345, then Query 2 then needs to find all rows in Table A where StaffNum is 12345, but also where Site = 'South' and EnterDate greater than the EnterDate returned in Query 1.

 

Cheers.