Working with the expression editor
You can enter the expression editor to add or edit an expression wherever you see the symbol 3 in the properties panel while editing a visualization. The 3 symbol indicates an expression field. Click 3 to enter the expression editor.
You can add expressions in two ways. Simple expressions can be inserted directly from the Fields panel by making selections from the available fields and functions. You can add more complex expressions by typing directly into the expression field.
Inserting an expression by selecting from the Fields panel
You can insert an expression by making selections from the Fields panel at the right-hand side of the expression editor dialog.
Do the following:
- If you want to limit the available fields to those from a particular table in your data model, select a table from the drop-down list marked Filter by table.
- Select a field from the Field drop-down list.
- Select the aggregation function you want to use. The functions available are from the group of basic aggregation functions.
-
Click Insert to insert the field and the function into the expression editor.
Tip noteIf you do not select an aggregation function, only the field will be inserted into the expression. -
Click Apply to close the Add expression dialog.
For a dimension or measure, you continue by adding descriptive data for the dimension or measure.
Adding or editing an expression by typing
Do the following:
-
Type the expression directly in the expression editor.
The field names you use in the expression are checked, and the syntax of the expression is validated.
Tip noteAs you type in the expression editor, the expression is validated. If there is an error, you see a hint about what is incorrect. Additional error information may be available by clicking the icon next to the hint.When you type the name of a function in the expression, a tooltip appears that provides information to help you enter the function correctly, including argument names and qualifiers.
Information noteThe tooltip for some chart functions shows the ALL qualifier. It is recommended that you do not use the ALL qualifier. Instead, use the set expression {1}.Each line in the expression editor is numbered and syntax highlighting is used.
-
Click Apply to close the Add expression dialog.
For a dimension or measure, you continue by adding descriptive data for the dimension or measure.
Auto-complete and color coding
When typing in the expression editor, you get an auto-complete list of matching fields, variables and functions to select from. The list is narrowed down as you continue to type. The color coding helps you to see where fields, variables and functions are used in the expression.
The color coding applies both in the auto-complete list and in the expression itself.
How names are interpreted
It is not recommended to name a variable identically to a field or a function in Qlik Sense. But if you do, you must know how to use them in an expression.
Example:
XXX is a field, a variable and a function. XXX will be interpreted as one of them depending on how you create the expression.
Expression | XXX interpreted as |
---|---|
$(XXX) | variable |
Count(XXX) | field |
XXX() | function |
Rules for expressions
The following rules apply for chart expressions:
-
All expressions return a number and/or a string, whichever is appropriate.
-
Logical functions and operators return 0 for False, -1 for True. Number-to-string conversions and string-to-number conversions are implicit.
-
Logical operators and functions interpret 0 as False and all else as True.
-
Expressions that cannot be correctly evaluated, for example as a result of incorrect parameters or functions, return NULL.
Detailed syntax help
You can open the online help with the full description of how to use the current function by double-clicking the function name in the expression editor and pressing Ctrl+H on the keyboard. This feature becomes available after having entered the first parenthesis of the expression after the function name.
Learn more
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!