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

how to use mapping table if there is a loop?

Hi All,

I'm not sure if this is a product limitation or bug.

i have a for loop to reload data for next database which will store qvd in another folder.within this for loop, i'm using a mapping table and applymap function.

When i use applymap, the value is not map as it supposed to be when i loop 2 databases. if i just use 1 db at a time, it's ok.

i can't drop a mapping table before the next command. is there a workaround for this? Doing a left join will be slow.

Any idea is very appreciated. Thanks!

1 Solution

Accepted Solutions
Not applicable
Author

Hi

Is the mapping load statement outside or within your for-loop?
If it's inside the loop I guess it could mean trouble since you will be creating the same table over and over again. Not sure really what the result of such on operation would be.
If this is your case, try adding a variable counter to the mapping table name.
Something like this maybe (untested):

set counter = 0;
for x = 0 to 10
set counter = counter + 1;
map$(counter):
mapping load ....
load applymap('map$(counter)', field, defaultvalue) as mapField ....
next

View solution in original post

2 Replies
Not applicable
Author

Hi

Is the mapping load statement outside or within your for-loop?
If it's inside the loop I guess it could mean trouble since you will be creating the same table over and over again. Not sure really what the result of such on operation would be.
If this is your case, try adding a variable counter to the mapping table name.
Something like this maybe (untested):

set counter = 0;
for x = 0 to 10
set counter = counter + 1;
map$(counter):
mapping load ....
load applymap('map$(counter)', field, defaultvalue) as mapField ....
next

Not applicable
Author

thanks fredrik! it works!