Deleting script variables

By Barry Harmsen

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.

About The Author

Barry Harmsen

Hi there, I'm Barry and I'm a Business Intelligence Consultant at Bitmetric and based in the Netherlands. Originally from a background of 'traditional' Data Warehousing, Business Intelligence and Performance Management, for the past 10 years I have been specializing in Qlik and a more user-centric form of BI. I have done numerous QlikView and Qlik Sense implementations in many different roles and industries. In 2012 I co-authored the book QlikView 11 for Developers. You can follow me on Twitter at @meneerharmsen.


  • 1
    October 9, 2010 - 21:23 | Permalink

    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.


    • 2
      October 18, 2010 - 14:28 | Permalink

      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.

  • 3
    February 24, 2016 - 15:48 | Permalink

    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 ?

  • 4
    July 16, 2018 - 15:49 | Permalink

    Is there a way to loop through all script variables that I could delete at the start / end of running the script?

  • 5
    Pranam K
    June 11, 2020 - 08:43 | Permalink

    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.


  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    Read previous post:
    Decile analysis

    Decile analysis is a popular segmentation tool. Where a pareto analysis splits the top 20% customers (or products, regions, etc.)...