Using quotation marks in the script
You can use quotation marks in script statements in a number of different ways.
Inside LOAD statements
In a LOAD statement the following symbols should be used as quotation marks:
Description | Symbol | ASCII | Example | |
Field names |
double quotation marks |
" " | 34 | "string" |
square brackets | [ ] | 91, 93 | [string] | |
grave accents | ` ` | 96 | `string` | |
String literals |
single quotation marks |
' ' |
39 | 'string' |
In SELECT statements
For a SELECT statement interpreted by the ODBC driver, it may be slightly different. Usually, you should use the straight double quotation marks (Alt + 0034) for field and table names, and the straight single quotation marks (Alt + 0039) for literals, and avoid using grave accents. However, some ODBC drivers not only accept grave accents as quotation marks, but also prefer them. In such a case, the generated SELECT statements contain grave accent quotation marks.
Microsoft Access quotation marks example
Microsoft Access ODBC Driver 3.4 (included in Microsoft Access 7.0) accepts the following quotation marks when analyzing the SELECT statement:
Field names and table names: |
|
|||
String literals: |
' ' |
Other databases may have different conventions.
Outside LOAD statements
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:
Example:
'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".
Example:
"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.
Example:
'12/31/96'
When this string is used as a part of an expression, it will in a first step be interpreted as the text string "12/31/96", which in turn may be interpreted as a date if the date format is ‘MM/DD/YY’. In that case it will be stored as a dual value with both a numeric and a textual representation.
Example:
12/31/96
When this string is used as a part of an expression, it will be interpreted numerically as 12 divided by 31 divided by 96.
Learn more
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!