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: 
priyarane
Specialist
Specialist

Dropping variables

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.

12 Replies
marcus_sommer

Then loop through the variables again and assign null() to them:

for ...

     let variable = null();

next

- Marcus

priyarane
Specialist
Specialist
Author

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;

chriscammers
Partner - Specialist
Partner - Specialist

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

sasiparupudi1
Master III
Master III

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;

priyarane
Specialist
Specialist
Author

Hi sasidhar,

Value is changing but name also should drop, how can I do it.

Thank you

tresesco
MVP
MVP

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.

jonathandienst
Partner - Champion III
Partner - Champion III

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();

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

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...

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein