Notification

This article is about Looker Studio. For Looker documentation, visit https://cloud.google.com/looker/docs/intro.

Literals

A literal represents a constant value of a built-in data type. Some, but not all, data types can be expressed as literals.

String literals

String literals must be quoted, either with single (') or double (") quotation marks.

Quoted literals:

Literal Sample usage Notes
Quoted string
  • "abc"
  • "it's"
  • 'it\'s'
  • 'Title: "Boy"'
  • Quoted strings enclosed by single (') quotes can contain unescaped double (") quotes, as well as the inverse.
  • Backslashes (\) introduce escape sequences. See the Escape Sequences table below.
  • Quoted strings cannot contain newlines, even when preceded by a backslash (\).
Raw string
  • R"abc+"
  • r'f\(abc,(.*),def\)'
  • Quoted literals that have the raw string literal prefix (r or R) are interpreted as raw/regex strings.
  • Backslash characters (\) do not act as escape characters. If a backslash followed by another character occurs inside the string literal, both characters are preserved.
  • A raw string cannot end with an odd number of backslashes.
  • Raw strings are useful for constructing regular expressions.

Escape sequences for string literals

The following table lists all valid escape sequences for representing non-alphanumeric characters in string literals. Any sequence not in this table produces an error.

Escape Sequence Description
\a Bell
\b Backspace
\f Formfeed
\n Newline
\r Carriage Return
\t Tab
\v Vertical Tab
\\ Backslash (\)
\? Question Mark (?)
\" Double Quote (")
\' Single Quote (')
\` Backtick (`)
\ooo Octal escape, with exactly 3 digits (in the range 0–7). Decodes to a single Unicode character (in string literals) or byte (in bytes literals).
\xhh or \Xhh Hex escape, with exactly 2 hex digits (0–9 or A–F or a–f). Decodes to a single Unicode character (in string literals) or byte (in bytes literals). Examples:
  • '\x41' == 'A'
  • '\x41B' is 'AB'
  • '\x4' is an error
\uhhhh Unicode escape, with lowercase 'u' and exactly 4 hex digits. Valid only in string literals or identifiers.
Note that the range D800-DFFF is not allowed, as these are surrogate unicode values.
\Uhhhhhhhh Unicode escape, with uppercase 'U' and exactly 8 hex digits. Valid only in string literals or identifiers.
The range D800-DFFF is not allowed, as these values are surrogate unicode values. Also, values greater than 10FFFF are not allowed.

Date literals

To use literal date and time values in a calculated field, you can precede the value with the appropriate marker:

Literal Canonical date format Sample usage
Date YYYY-[M]M-[D]D DATE '2021-4-1'
Date and time YYYY-[M]M-[D]D [[H]H:[M]M:[S]S] DATETIME '2021-5-29 23:59:59'

Numeric literals

Enter numeric literals using unquoted integer or floating point values. For example:

Literal Examples Sample usage
Integer 1, -1, 0
  • 2 + 2
  • CASE WHEN Cost > 100 THEN ...
Floating point 1.23, -1.2345
  • SQRT(3.14)
  • FLOOR(-42.123)

Boolean literals

Use the literal values true and false when evaluating Boolean expressions. For example:

IF(Boolean field = true, "yes","no")

IF(Boolean field = false, "no","yes")

Note: while the above is syntactically correct, you can simplify this by referencing the boolean field's value directly:

IF(Boolean field, "yes","no")

IF(not Boolean field, "yes","no")

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Main menu
5235983405541994755
true
Search Help Center
true
true
true
true
true
102097
false
false