Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
Not applicable

Clear variable since the script

Hello,

I've many variables in my application and I want to clear them with a loop in the script. Can you help me?

Thanks you

4 Replies

Re: Clear variable since the script

In the script you can set the variables to null by doing vVar = Null();

I usually set the variables, which I am not going to use in the front end of the application, at very end tab of my script.

HTH

Best,

Sunny

Re: Clear variable since the script

If you clear the variable in the end of the script using

     Let vVariable = Null() ;

or

     Set vVariable = ;

and delete the variable in Settings > Variable Overview, the variable will be automatically deleted at the end of the script every time.

HIC

Re: Clear variable since the script

Maybe this proves to be an interesting technique for you:

  • At the start of your script, create an INLINE table with variable names, variable values and variable assignment types (LET or SET)
  • Next add a FOR loop that walks the table rows and performs a SET or LET for each variable (put this code in a SUB)
  • At the end of your script, add another FOR loop that does what has been suggested before, SET every variable in the table to NULL() or to ... nothing. (put this code in another SUB)

This only works for variables that were not defined in the Variable Overview. Those cannot be "uncreated" in the script.

With respect to your original question, I don't know about any other LOOP-solution as QV cannot know beforehand which variables you want to drop and which ones you want to keep.

Re: Clear variable since the script

If you want a very flexible configuration in your QV documents, you could store the variable definitions in an external file (e.g. Excel)

You'll have to be careful when loading these definitions because $-sign substitution wil try to play tricks with you all the time...