Skip to main content Skip to complementary content

Working with variables and expressions in your PixelPerfect template

You can add variables from the Qlik Sense app to your PixelPerfect template to create dynamic content. Expressions using Qlik Sense syntax can be added directly, allowing you to store and use individual calculations in reports.

Variables and expressions can be added as usable data bindings from the Database icon with plus symbol Field List menu.

When to use them

Variables and expressions are useful to add to your report. Here are some examples:

  • Use a scripted variable to store the date of the last time the app was reloaded. This could be inserted on the front page of the report.

  • Add an expression to calculate a key metric, such as total sales. Then, combine the expression into native PixelPerfect text to represent data using natural language and PixelPerfect formatting.

Adding a variable

You can add a variable that exists in the Qlik Sense app as a data binding.

  1. Open the Database icon with plus symbol Field List menu available from the right-side panel in the designer.

  2. Click the plus icon next to Variables.

  3. Select the Qlik Sense variable you want to add. Click the Plus icon next to it.

    The data binding is added.

Adding an expression

You can add Qlik Sense expressions directly as data bindings.

  1. Open the Database icon with plus symbol Field List menu available from the right-side panel in the designer.

  2. Click the plus icon next to Expressions.

  3. Select the Qlik Sense variable you want to add. Click the Plus icon next to it.

    The data binding is added.

Example - Using a variable to display date of last app reload

Refer to the example app sources here: Example materials - In-app reporting. Upload the app and data files into a space, and then reload the app. You are ready to complete the example.

In this example, we use Qlik Sense variables to compose a text string representing the date on which the app data was last reloaded.

  1. Create a new PixelPerfect template.

  2. Open the Database icon with plus symbol Field List in the designer.

    Field List menu in the PixelPerfect designer

    The 'Field List' menu expanded from the right side panel in the PixelPerfect designer
  3. Expand Variables. Click the plus icon to add a new variable.

  4. Click the plus icon next to vLastReloadYear. This is a scripted variable from the app. The variable contains the expression =year(now()) and is only updated when the app reloads.

  5. You are brought back to the main Database icon with plus symbol Field List menu. Click the plus icon next to Variables.

  6. Click the plus icon next to vLastReloadMonth. This is a scripted variable from the app. The variable contains the expression =month(now()) and is only updated when the app reloads.

  7. You are brought back to the main Database icon with plus symbol Field List menu. Click the plus icon next to Variables.

  8. Click the plus icon next to vLastReloadDay. This is a scripted variable from the app. The variable contains the expression =day(now()) and is only updated when the app reloads.

  9. From the toolbox panel on the left side of the designer, drag a Database icon with plus symbol Label object onto the TopMargin1 band in your template.

  10. Select the label. Click the bold f icon near the label to open the Expression Editor.

  11. In the Expression Editor, enter the following expression:

    Concat('App last reloaded: ', [vLastReloadYear], '-', [vLastReloadMonth], '-', [vLastReloadDay])
  12. Increase the width of the label so that all text can be displayed on a single line.

    Label containing string composition with variables, added to template. The image also shows the data sources that were used in the label expression.

    Report template with a label containing text and a variable value, added in the top margin
  13. Customize and style the label properties if desired.

  14. In the top right corner, click Save template.

  15. Click Preview report. Download the report and open it.

Report preview

Generated report showing the variable value and concatenated text. In this case, the complete string displays the time at which the app was last reloaded

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!