This post was inspired by a gentleman I met at a QlikTech Partner meeting who was adamant that a script variable, once created, cannot be deleted. Of course this can be done, and here’s how.
If the variable already exists in the front-end, we first have to remove it there. This is done by opening the variable overview (Ctrl + Alt + V), selecting the variable and pressing “Remove”.
The next step is to assign a value of null() to the variable in the script. For example, to delete the variable vVariableToRemove we would use the following script:
LET vVariableToRemove = null();
And that’s it, no more unwanted script variables cluttering up your front-end variable overview. You can download an example qvw by clicking here.
7 Comments
I’ve used this technique for a while. It’s a shame that setting a variable to null() doesn’t remove it from the front end automatically. At least you can delete them and stop them coming back again with this tip.
A built in option to export all variables and their values would be good also. Presently I create an Input Box and add all variables and then copy the data from there into Excel for cleaning up.
Steve
Be careful when exporting expression variables to Excel. If they are long expressions it will chop them off after so many chars. I didn’t count, but assume it is around 255.
hi Barry,
I create the variables using the script, the number of variables will vary so i have to delete all of those which i created during the last reload.
basicaly, its a case when variables already exist. when i am trying to loop on those variables and setting them null(); it is nullifying those but don’t delete them (i still see them in the variables window).
how to completely delete them before recreating them ?
Is there a way to loop through all script variables that I could delete at the start / end of running the script?
Hi Steve Dark/Team,
I want to delete a variable from the UI using “DestroyVariableById”.
If not, using macro’s also fine. Can you please help me on this. Suggestions welcome.
As you said, you create an Input Box and add all variables and then copy the data from there into Excel for cleaning up. How do you accomplish the same. Can you please share an example code snippet.
Thanks,
Pranam