Early Access: The content on this website is provided for informational purposes only in connection with pre-General Availability Qlik Products.
All content is subject to change and is provided without warranty.
Skip to main content Skip to complementary content

Using variables and expressions in your Excel report template

Add variables and expressions to your report template as objects. You can use a variable or expression to dynamically store a value or calculation that can be centrally modified and re-used across a report.

Variables

You can insert variables from Qlik Sense into the template. Like other template objects you create, a variable is added as an object in the template configuration, and is accessible from the Qlik add-in window in Excel. Add an instance of the variable object as a variable tag.

You can add both scripted variables and variables defined in sheet view.

Adding a variable

  1. Click the Variables icon on the top toolbar of the add-in.

  2. Click Add variable. A list of available variables appears.

    Variables and expressions tab in Excel add-in, allowing you to add a new variable or revisit a variable you have already added

    'Variables and expressions' tab in Excel add-in, from which you can add/modify existing variable objects you have added, or add a new variable
  3. Click the Plus symbol icon to the right of an existing variable to add it.

    Select a variable you want to add to the template

    Select the variable to add to the template from the available list
  4. The variable tag is inserted in the currently highlighted cell. The settings page for the variable appears. Under Expression, you can view a Preview of the current variable value.

    It is recommended to provide a unique Name to the variable so you can identify it in the add-in if you later need to change its settings.

  5. Adjust any other parameters as needed.

Revisit any variable you have added at any point for modifications to its configuration, to locate it in the workbook, or to add another instance of it to the workbook. Click the Variables icon in the add-in to open the Variables and expressions landing page, and click Right-directional arrow to navigate to the cell where it is inserted. Adjust any settings as needed in the add-in.

For information on other important actions you need to complete with variables, see the following:

Expressions

Add expressions as objects using Qlik Sense syntax and functions. Like other template objects you create, an expression is added as an object in the template configuration, and is accessible from the Qlik add-in window in Excel. Add an instance of the expression object as an expression tag.

Popular expressions you might want to add include:

  • =Count(distinct <your dimension field>): returns the number of unique values for a dimension field you define in the expression (for example, Customer or Product).

  • =today(): returns the current date.

  • =year(now): returns the current year.

Adding an expression

  1. Click the Variables icon on the top toolbar of the add-in.

  2. Click Add expression. A list of available expressions appears.

    Variables and expressions tab in Excel add-in, allowing you to add a new expression or revisit an expression you have already added

    'Variables and expressions' tab in Excel add-in, from which you can add/modify existing or new expressions
  3. Click the Plus symbol icon to the right of an existing expression to add it. Follow the same steps for adding an existing variable: Adding a variable.

  4. If you need to create a new expression instead, click Create expression.

  5. Configure the new expression by adding a Name and Description (optional), and then define the Expression.

    Select a variable you want to add to the template

    Create an expression using the Excel add-in, defining a Name, description, and expression (calculation)
  6. Check the Preview value under the Expression field to make sure you have configured the expression correctly, and click Create.

The expression object is created and will be accessible in the add-in window. The expression tag is also inserted in the currently selected cell.

Revisit any expression you have added at any point for modifications to its configuration, to locate it in the workbook, or to add another instance of it to the workbook. Click the Variables icon in the add-in to open the Variables and expressions landing page, and click Right-directional arrow to navigate to the cell where it is inserted. Adjust any settings as needed in the add-in.

For information on other important actions you need to complete with variables, see the following:

Formatting a variable or expression

Apply native Excel formatting to the cells containing your variable and expression tags. This can include font styling, number formatting, and other customizations. The formatting is applied to the report output.

Removing a variable or expression

You can remove a variable or expression from the report template, and from the list of that object type in the add-in pane.

  1. Select the cell where the object is added.

  2. Click Delete in the bottom of the add-in window.

This removes the tags and the object from the corresponding object list.

If you instead use Excel features to delete an object, it will not be inserted in the generated report. However, the object will still appear in the list of added objects. This means you can easily re-add the object later.

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!