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