Script Variable In QlikView Application

Introduction

A script variable can be used to set the environment. In a QlikView application, variables are applied after the script executes. The variables are used before the script execution and are dropped after the script execution. For script variables there is no inherent function and no specific command.

The following  is the basic procedure for using script variables in a QlikView application.

Step 1: Open the QlikView application

In this step you need to open the QlikView application then go to File-> New then this window will be opened.

After clicking New option


Step 2:
Open edit script

The second step is to open the edit script window.

window of edit script


Then, this window will be opened.

window


  Step 3:
Code of edit script and reload it

Then, write this code in the edit script.

code script


 Step 4:
Save file

The next step is to save our QlikView file in the location you want and click on the Save button.

save file

Example

Here I used the two variables Date and Time that shows the current date and time and also explains how to use script variables.

Step 5: Sheet property window

There is no field to open because we did not upload any table and database. So simply click on the OK button.

Sheet Property


Step 6:
Select text object

Now right-click anywhere in the blank main sheet and select:
New Sheet Object->Text Object, then the window will be opened.

select Text object

Step 7: New text object window

In this window, we provide the text of our variable that we declared in the edit script window then click on the OK button.

New Text

This window will show the current date.

main


Step 8:
Select another text object

Again, right-click anywhere in the blank main sheet and select:
New Sheet Object->Text Object, then the following window will be opened.

select Text object1


Step 9:
Again a new text object window will be opened

In this window, we provide the text of our variable that we declared in the edit script window then click on the OK button.

New Text1


This window will show the current time.

main1


Step 10:
In the variable overview you can check these variables, Setting->Variable overview.

variable overview


Now you will see this window. Here you can see both script variables with definition and click on the OK button.

variable

Step 11: Drop script variable

For dropping any variable, we should provide a null value to the script variable. If you want to drop a variable after script execution then again open the edit script and you need to write this code and reload it.

drop variable

Example

Suppose you want to drop a date variable, then you should provide a null value for the date variable.

Step 12: Sheet property window

There is no field to open because we did not upload any table and database. So simply click on the OK button.

Sheet Property1


This window will show the drop date variable.

main2


Step 13:
In the variable overview you can check these variables, Setting->Variable overview.

variable overview1


Now you will see this window. Here you can see a drop script Date variable. There is no definition for any drop script variable and click on the OK button.

variable1

If you want drop a Time variable then you need to use the same process with the Time variable.

Summary

This article is very simple to understand. It provided basic concepts of Script variables and also introduced how to use script variables before executing a script and how to drop them.