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

How to create double for loop with Exception

Hi, 

I have a double loop like :

 

LET vNoOfDB= FieldValueCount('Table1');
LET vNoOfTables = NoOfRows('Table1');

For i = 0 to 10 

     let = Peek (Field1, $(i), Table1

      For j = 0 to 5

               let = Peek (Field1, $(i), Table2

            Some code

Next

Next

And it's working fine, and what I need to loop sometimes the only specific field in Table1 and Table2: 

 

Like 

Table1 :

id value

1   2

2   4

Table2:

id  value 

1   2

10  5

To summarize I need loop only id 1 because it's exists in both tables 

Thank you

Labels (2)
1 Solution

Accepted Solutions
Jogi
Contributor III
Contributor III
Author

Hi all, I manged it to create separate if condition before second loop, thank you all 

View solution in original post

3 Replies
Anil_Babu_Samineni

Perhaps this?

LET vNoOfDB= FieldValueCount('Table1');
LET vNoOfTables = NoOfRows('Table1');
For i = 0 to 10
let = Peek ('Field1', $(i), 'Table1')
Table1:
Load * Inline [
id, value
1, 2
2, 4
];
For j = 0 to 5
let = Peek ('Field1', $(j), 'Table2')
Concatenate (Table1)
Table2:
Load * Inline [
id, value
1, 2
10, 5
] Where Exists(id,id);
Next j
Next i

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
Brett_Bleess
Former Employee
Former Employee

Jogi, did Anil's post get you what you needed for your use case?  If so, be sure to return to the thread and use the Accept as Solution button on his post to give him credit and let the other Community Members know what worked.  If you still require further help, leave an update post.

You may want to try the Design Blog area too if Anil's post did not quite get you all the way there.

 https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

This area of the Community is mostly how-to posts from our internal experts, so you may find it quite useful in helping you flesh out ideas going forward.

One specific post that may be related is the following I think:

https://community.qlik.com/t5/Qlik-Design-Blog/Preceding-Load/ba-p/1469534

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Jogi
Contributor III
Contributor III
Author

Hi all, I manged it to create separate if condition before second loop, thank you all