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. Expressions can be created using the Fields, Functions, Variables, and Set expressions sections by making selections and inserting them into the expression field. You can edit the inserted expressions and add more complex expressions by typing directly into the expression field. You can undo an action by clicking the Undo button (B).
Inserting an expression using Fields
You can insert an expression by making selections from the Fields section at the righthand 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 Filter by table dropdown list.
 Select a field from the Field dropdown list.
 Select the aggregation function you want to use. The functions available are from the group of basic aggregation functions.
 If you want to insert the current selection as a set expression in your aggregation, use the Set expression check box. The current selection is always based on the default state.
 If you want to insert a Distinct or a Total clause together with the aggregation function, use the check boxes for each clause. Each clause can be used separately.

Click Insert to insert the field and the function into the expression field.
Tip: If you do not select an aggregation function, only the field will be inserted into the expression. Clauses can only be added if you select an aggregation function. 
Click Apply to close the Add expression dialog.
For a dimension or measure, you continue by adding descriptive data for the dimension or measure.
Inserting a function using Functions
You can insert more than the basic aggregation functions by making selections from the Functions section at the righthand side of the expression editor dialog.
 If you want to filter the list of available functions, select a function category from the Function category dropdown list.

Select a function from the Function name dropdown list.
You see a preview of the function.

Click Insert to insert the function and the first parenthesis into the expression field.
 Type the rest of the expression in the expression editor according to the syntax.

Click Apply to close the Add expression dialog.
For a dimension or measure, you continue by adding descriptive data for the dimension or measure.
Inserting a variable using Variables
You can insert a variable by making selections from the Variables section at the righthand side of the expression editor dialog.
 If you want system variables to appear in the list of available variables use the Show system variables checkbox.

Select a variable from the Variable dropdown list.
You see a Definition and Value of the variable, if available.

Click Insert to insert the variable into the expression field.

Click Apply to close the Add expression dialog.
For a dimension or measure, you continue by adding descriptive data for the dimension or measure.
Inserting a set expression using Set expressions
You can insert a set expression by making selections from the Set expressions section at the righthand side of the expression editor dialog.

Select whether to Use current selections or Use bookmark, as a set expression.
You can only Use current selections if a selection has been made in the app. You can only Use bookmark if a bookmark is available. Use the Bookmark dropdown menu to choose between bookmarks.
 If you have defined alternate states, you can change the alternate state which the set expression is based on. Select the alternate state from Alternate state dropdown menu.

Click Insert to insert the set expression into the expression field.

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 field.
The field names you use in the expression are checked, and the syntax of the expression is validated.
Tip: As 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.
Note: The 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.
Autocomplete, evaluation and color coding
When typing in the expression editor, you get an autocomplete 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 autocomplete list and in the expression itself.
You can verify that any dollarsign expansions added in your expression give the correct result, by checking the expression evaluation, in the dollarsign expansion preview.
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. Numbertostring conversions and stringtonumber 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 activate help mode by clicking the Help button (D). When active, all functions in the expression editor act like hyperlinks. Clicking on a function opens a browser tab to the online help section with the full description of how to use the specific function. When a function is clicked, help mode is exited.