You can use quotation marks in script statements in a number of different ways.
- Inside LOAD statements
- In SELECT statements
- Outside LOAD statements
- Out-of-context field references and table references
- Difference between names and literals
- Difference between numbers and string literals
- Using single quote characters in a string
In a LOAD statement the following symbols should be used as quotation marks:
double quotation marks
|single quotation marks||
For a SELECT
statement interpreted by an
Microsoft Access quotation marks example
Field names and table names:
Other databases may have different conventions.
Outside a LOAD statement, in places where Qlik Sense expects an expression, double quotation marks denote a variable reference and not a field reference. If you use double quotation marks, the enclosed string will be interpreted as a variable and the value of the variable will be used.
Out-of-context field references and table references
Some script functions refer to fields that have already been created, or are in the output of a LOAD statement, for example Exists() and Peek(). These field references are called out-of-context field references, as opposed to source field references that refer to fields that are in context, that is, in the input table of the LOAD statement.
Out-of-context field references and table references should be regarded as literals and therefore need single quotation marks.
Difference between names and literals
The difference between names and literals becomes clearer comparing the following examples:
'Sweden' as Country
When this expression is used as a part of the field list in a LOAD or SELECT statement, the text string "Sweden" will be loaded as field value into the Qlik Sense field "Country".
"land" as Country
When this expression is used as a part of the field list in a LOAD or SELECT statement, the content of the database field or table column named "land" will be loaded as field values into the Qlik Sense field "Country". This means. that land will be treated as a field reference.
Difference between numbers and string literals
The difference between numbers and string literals becomes clearer comparing the following examples.
When this string is used as a part of an expression, it will in a first step be interpreted as the text string "
When this string is used as a part of an expression, it will be interpreted numerically as
Using single quote characters in a string
If you need to include single quote characters in a string, you can use an extra single quote as an escape character.
The string '10 O''clock News' will be interpreted as 10 O'clock News.