Qlik Best Practice: Script Variables in Qlik - Ometis Blog

Qlik Best Practice: Script Variables

Posted on: 24th January 2019, 11:41 am

In the latest instalment of our Best Practice series, we’re taking a closer look at script variables in Qlik and the best formats to use.

Script variables in Qlik provide developers with the ability to store static values or the result of a calculation. There are two methods for defining a variable:

1. SET variablename = string;
Everything to the right of the equal sign is stored as a text value.

2. LET variablename = expression;
Everything to the right of the equal sign is evaluated as an expression and the result is stored as the value.

It is recommended that you follow these guidelines when using variables in the Data Load Editor:
Prefix the variable name with a ‘v’, ‘var’ or similar. The main point here is to be consistent across your apps/team, avoid using a mixture. Being consistent will help if you rely on the script auto-complete functionality.

Camel case should be used when naming a variable. For example, after the prefix each additional word should be capitalised i.e. vMaxDate.

For evaluated variables (LET), TRACE the value to the reload console. It can help debug the script or reassure the developer that it has evaluated as expected.

Any script variables not required in the UI (user interface) should be dropped before the end of the script. This is achieved by defining the value of the variable as null:

Script Variables in Qlik

Follow these simple rules and you’ll ensure efficient use of your Qlik software and don’t forget to stay up-to-date with all the latest Qlik tips and tricks by following us on LinkedIn, Twitter and YouTube.

As always, you can stay abreast of the latest Qlik news and information by following the ometis social channels via Twitter and LinkedIn. You will also find best practice walk-throughs and latest feature reviews on the official ometis YouTube channel and our blog.

By Chris Lofthouse


Leave a Reply

Your email address will not be published. Required fields are marked *

Get the most from Qlik Sense

Our range of Qlik Sense add-ons will enable you to get the most out of your platform.