Creating a variable
A variable in Qlik Sense is a named entity, containing a data value. When a variable is used in an expression, it is substituted by its value or the variable's definition. Variables are defined using the variables dialog or in the script using the data load editor.
You can create a new variable from the variables dialog, when editing a sheet in an unpublished app.
You can duplicate an existing variable by clicking and selecting Duplicate.
For a visual demo about creating variables, see Creating a variable.
Do the following:
When editing a sheet, click in the edit bar on the sheet to open the variables dialog.
The variables overview opens.
Click Create new.
The following input fields for the variable are displayed:
- Name (mandatory)
Press Esc or click Cancel if you want to cancel creating the new variable.
Type a name for the variable (mandatory). Use the following guidelines when choosing a name:
- You cannot change the name once you have created the variable.
- Use a letter as the first character, do not use a number or a symbol.
It is not recommended to name a variable identically to a field or a function in Qlik Sense.
For more information, see How names are interpreted.
- Do not use the following characters when naming a variable: $ ( ) [ ] "
The name must be unique. You cannot name a variable using a name used for a reserved variable or a system variable. These variables are not listed in the variables dialog, but if you are not allowed to use a certain name, even though you cannot find a duplicate in the variables dialog, a reserved variable or a system variable already has this name.
- A long name is not recommended. If a variable's name is too long, the name cannot be fully displayed in the variables overview.
Optionally, type a description for the variable.
Create a definition for the variable. You can enter the expression editor by clicking .
For more information, see Working with the expression editor.
Set the variable's value to today's date, presented as a number:
Optionally, enter tags for the variable.
Click Create to save the variable.