Using expressions in visualizations

Visualizations in Qlik Sense are built from charts, which in turn, are built from dimensions and measures, depending on the type of chart. Visualizations can have titles, subtitles, footnotes, and other elements to help convey information. All of the elements that make up a visualization can be simple: a dimension consisting of a field representing data, a title consisting of text, for example.

For visualizations that contain measures, the measures are calculations based on fields, for example Sum(Cost), which means all the values of the field Cost are aggregated using the function Sum. In other words, Sum(Cost) is an expression.

What is an expression?

An expression is a combination of functions, fields, and mathematical operators (+ * / =). Expressions are used to process data in the app in order to produce a result that can be seen in a visualization. They are not limited to use in measures. You can build visualizations that are more dynamic and powerful by using expressions for titles, subtitles, footnotes, and even dimensions.

This means, for example, that instead of the title of a visualization being static text, it can be made from an expression whose result changes depending on the selections made.

Where can I use expressions?

Expressions can be used in a visualization wherever the symbol 3 is seen in the properties panel while editing a visualization. The 3 symbol indicates an expression field. By clicking 3, you enter the expression editor, which is designed to help you build and edit expressions. Expressions can also be entered directly into the expression field, without using the expression editor.

An expression cannot be saved directly as a master item, but if an expression is used in a measure or dimension, which is then saved as a master item, with its descriptive data, such as name, description, and tags, the expression in the measure or dimension is preserved.

Expressions are used both in scripts and in chart visualizations. They can be simple, involving only basic calculations, or complex, involving functions fields and operators.Expressions can be used in several different situations. The difference between measures and expressions is that expressions have no name or descriptive data.

Note: In a script, an expression is evaluated as the script execution passes it by. In visualizations (including charts and tables), expressions are evaluated automatically whenever any of the fields, variables or functions that the expression contains change value or logical status. A few differences exist between script expressions and chart expressions in terms of syntax and available functions.

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?