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

dropping all the tables that fulfill a condition

i want to drop multiples tables after exxtracting the necessary data from them. I used the solution (from https://community.qlik.com/t5/QlikView-App-Dev/Delete-all-resident-tables/td-p/221483) : 

let numTables = NoOfTables();
for i=1 to $(numTables)
let tt = TableName(0);
if ('$(tt)' <> 'Data_22')
drop table [$(tt)];
endif
next i;

This  seem to be working only the first time i used it to drop tables. I used it multiples times within the script editor and only the first time was succesfull. Can someone pls help me out with this. Thank you in advance.

Labels (4)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I find it easier and more reliable to loop from last table number to first. 

FOR i = NoOfTables()-1 to 0 STEP -1
let tt = TableName($(i));
if ('$(tt)' <> 'Data_22')
drop table [$(tt)];
endif
next i;

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com 

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I find it easier and more reliable to loop from last table number to first. 

FOR i = NoOfTables()-1 to 0 STEP -1
let tt = TableName($(i));
if ('$(tt)' <> 'Data_22')
drop table [$(tt)];
endif
next i;

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com 

yacine
Contributor II
Contributor II
Author

thank you mister.