Skip to main content Skip to complementary content

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 overview or in the script using the data load editor.

You can create a new variable from the variables overview, when editing a sheet in an unpublished app.

Do the following:

  1. When editing a sheet, click Ò in the edit bar on the sheet to open the variables overview.

    The variables overview opens.

  2. Click Create new.

    The following input fields for the variable are displayed:

    • Name (mandatory)
    • Definition
    • Description
    • Tags

    Press Esc or click Ö if you want to cancel creating the new variable. If all input fields are empty, you can also cancel by clicking outside the new variable section in the variables overview or by clicking outside the variables overview window.

  3. 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.

      See: How names are interpreted

    • Some characters have specific uses in Qlik Sense expressions, therefore do not use the following characters when naming a variable: $ ( ) [ ] "
    • The name must be unique. You are not allowed to name a variable identically to a reserved variable or a system variable. These variables are not listed in the variables overview, but if you are not allowed to use a certain name, even though you cannot find a duplicate in the variables overview, 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.
  4. Create a definition for the variable (optional). You can enter the expression editor by clicking 3.

    See: Working with the expression editor

    Example:  

    Set the variable's value to today's date, presented as a number: 

    Num(Today())

  5. Type a description for the variable (optional).

  6. Add tags by typing and click P or press Enter (optional).

  7. Save the variable by clicking @. You can also save by clicking outside the new variable's section in the variables overview or by clicking outside the variables overview window.

    The variable is added to the top of the list and marked with New.

The new variable is created.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!