Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community,
How to drop variables.
I have 50 variables and I have loaded from excel by for loop and I wanted to drop all together.
Note: I have all the variable names in excel.
Then loop through the variables again and assign null() to them:
for ...
let variable = null();
next
- Marcus
This is the for loop I am using so how to use your look, Could you please let me know briefly?
let vi=noofrows('Tablenam');
for i=0 to (vi-1)
let vVar=peek('vVarname',i,'Expression')
let $(vVar)=peek('Expression',i,'Expression')
next i;
you could drop the variables once they are in the front end if you modify this macro I found on Qlik Maven
If these are not supposed to be in the document then I would set them to Null() before the end of the script.
Thanks
Chris
Try
let vi=noofrows('Tablenam');
for i=0 to (vi-1)
//let vVar=peek('vVarname',i,'Expression');
//let $(vVar)=peek('Expression',i,'Expression');
let vVar=Null();
next i;
Hi sasidhar,
Value is changing but name also should drop, how can I do it.
Thank you
Variables (names) can't be deleted that way. You can manually delete them from Settings->Variable Overview. However, script variables would get populated again after a reload.
If a variable does not exist when the reload starts, and is set to a value in the script and set to null before he script closes, it will be automagically dropped.
Use
Set vVar =;
or
Let vVar = null();
During development and debugging, these variables are sometimes not dropped when the the script is aborted before completion. For this reason, I define script-only variables with a z prefix (rather than the v prefix which I normally use).
Once development is complete, I can sort the variables in the variabe overview and delete all the z* variables. I can also see if a set var = null is missing because the z* variable survives the reload.
Just a tip...