11 Replies Latest reply: May 21, 2018 5:21 AM by Diego Alejandro Barboza Branched to a new discussion. RSS

    How do I clear all QlikSense variables?

    Michael Holian

      It seems QlikSense variables are stored even after the variable definition is deleted, which can cause unexpected results. It can make things very difficult to debug when there is no variable defined in the load script, but it is used (and has a value). How can I clear ALL variables at the start of my load script (without knowing variable names)?



        • Re: How do I clear all QlikSense variables?
          Rob Wunderlich

          I can't reproduce the described behavior. When I delete a variable from the sheet editor, it o longer ha a value in the script. I am using Sense desktop 2.2.3. What version are you using? Can you post a qvf that demonstrates the problem?





          • Re: How do I clear all QlikSense variables?
            Phaneendra Kunche

            It is a odd behavior, and haven't see this in my versions 2.0.1, 2.2.3, 2.2.4 & 3.0.


            Try using this extension and export all variables and copy & paste them back to load script and modify them something like...


            Let vCurrMonth ='';

            Let vPrevMonth ='';


            Qlik Branch

            • Re: How do I clear all QlikSense variables?

              I think the variable will no longer exist when you reload the it. Hope it helps!

              • Re: How do I clear all QlikSense variables?
                Michael Holian

                We are using 2.2.4. My understanding is that this is known, accepted behavior. Let's say I have these two lines:

                   LET vTest = 3;

                   vTest = $(vTest) * 2;

                I have a sheet with a KPI displaying $(vTest). I hit Load, and it shows 6. I can hit Load a hundred times, and it will always display 6. Now I make this change:

                  LET vTestTypo = 3;

                  vTest = $(vTest) * 2;

                Now it displays 12. Wait, what? Let me trying loading again, without changing anything. Now it displays 24. Load again, it shows 48. I'm expecting 6. The reason is that QlikSense saves variables with their most recent value, regardless of whether they are in the load script. After the initial run, when the typo is introduced, it remembers vTest was 6, so it doubles it (then again, and again).


                This is not the only downside of this "variables persist" design, but it's the easiest to demonstrate. What I would like to do it clear out ALL variables at the start of my load script, delete them or at least set them to NULL. According to my Googling, something similar can be done in QlikView, but it requires functions/macros that QlikSense does not have. Is there a way to get a list of all QlikSense variables in the load script, and clear out their values?

                  • Re: How do I clear all QlikSense variables?
                    Azucena Coronel

                    Hi Michael!


                    I'm having also troubles with this behaviour.

                    Did you find a solution for it?

                    I'm in QS desktop 3.1




                    • Re: How do I clear all QlikSense variables?
                      Diego Alejandro Barboza

                      First of all, let me clarify that you do not need to declare all variables that you will use at the beginning of the script: If it was used on a previous run of the script or if it was created from the user interface, it will be saved and you can call it again whenever you want during the script (using the last defined value) The first time you run the script, you create the variable.

                         LET vTest = 3;

                         vTest = $(vTest) * 2;


                      If you don't change the script, the variable already exists with value six (6) , but when you reach here, you redefine the value of vTest again to three(3) and then to six (6)

                         LET vTest = 3;

                         vTest = $(vTest) * 2;


                      Qlik remembers the value of this variable, so if you don't change it, Qlik will only read this:

                        vTest = $(vTest) * 2;


                      This is working as intended, since the Idea is that (in some cases) you can define Variables from the user interface or from outside the application (via EDX or QMC in QlikView, for instance)

                    • Re: How do I clear all QlikSense variables?
                      Fei Xu

                      In my case I have duplicated lines in the variable overview in Sense application (I have no idea how could this happen):


                      The variables (defined in script) cannot be edited / deleted in the front. To remove them, you need to go to script and do "set variable=;" (see Deleting a variable ‒ Qlik Sense in the official help page), reload, and then edit / delete the variable in the front.


                      In my case, I have to reload four times, each time one of the duplicated variable became editable then I deleted one.


                      Please note this works in Sense desktop 10.3.4. When I tried the same steps first in a Sense 3.1 server, it did not work (Every time I reload the script, one new editable variable appears. I can only delete this new created one. I still cannot do anything to the existing duplicated ones).


                      Just hope this can provide some help.