Data Types

Data types specify the kind of value a token represents (e.g., text, number, etc.). In Analytics, you can create custom fields for use in reports with the following data types:

  • Number: Represents numeric values used for calculations, such as sales figures, quantities, or metrics.

  • String: A sequence of characters, typically used for text-based data like names, categories, or descriptions.

  • Date and Time: Stores specific date and time values, allowing you to track and analyze time-sensitive data, such as event timestamps or log entries.

  • Date Alias: A predefined label or alias for a specific date field, simplifying date-related calculations or filtering in reports.

  • Date Interval: Represents a span of time between two dates, often used for calculating durations like project timelines or time differences.

  • Boolean/Condition: Holds true/false values based on logical conditions, used to evaluate criteria or trigger specific actions in reports.

  • Field: Refers to any custom or predefined data field in Analytics, used for organizing and categorizing data in reports. It could represent any data type (e.g., text, number, date) used for reporting purposes.

Number

A number is a user-defined data type that represents a numeric value, which can be used for mathematical calculations and operations. It can either be an integer (whole number) or a float (decimal number), with a dot (.) as the decimal separator. For example:

  • 2000

  • 2000.25

String

A string is a user-defined data type used to represent a sequence of characters, such as letters, numbers, symbols, or spaces enclosed in single quotes. In order to use a single quote within the string, it must be escaped by the \ character. The \ must also be escaped. For example:

Input Output

‘My string’

My string

‘125’

125

‘A single quote (\’) requires escape'

A single quote (’) requires escape

‘A backslash (\\) also requires escape'

A backslash (\) also requires escape

‘\\\’'

\'

‘\\’'

invalid

‘Supports special chars !@#$%"&*()<>,.:/[]{} …’

Supports special chars !@#$%"&*()<>,.:/[]{} …

Date and Time

Date and time are data types used to represent a date or datetime, wrapped by single quotes. The format is YYYY-MM-DD HH:MM:SS.mmm. For example:

Valid Invalid
‘2022-01-01’ ‘2022-01-99
'2022-01-01 01:01:25' ‘2022-13-01 25:00:00’
'2022-01-01 01:01:25.123' '2022-01-01 01:01:25.ABC'

Note: Invalid datetime formats will be considered as strings.

Date Alias

A date alias refers to a dynamic date based on system datetime. It should not be wrapped in single quotes when used. For example:

  • yesterday

  • max

  • tomorrow

Date Interval

A date interval refers to a range or span of time between two specific dates or timestamps. It is typically used to represent durations, time differences, or elapsed periods between two dates (to be used by date functions). Do not wrap in single quotes. For example:

  • year

  • quarter

  • month

  • dayofyear

  • day

  • week

  • weekday

  • hour

  • minute

  • second

  • millisecond

  • microsecond

  • nanosecond

Note: Some date intervals, such as year, month, and day, also serve as function names. The context of the token is crucial for proper identification.

Boolean/Condition

Any expression resulting in a true/false value used within functions such as CASE and IF. For example:

  • field1 > field2

  • field1 = ‘My text’

  • boolean_field

  • field1 > field2 AND (field1 = ‘My Text’ OR boolean_field)

See Operators for more information.

Field

A regular field or custom field available in the widget. The field type determines the validation requirements and corresponds to a specific data type, such as text, number, date, or boolean.

Note: The type of a custom field is determined by its format, which is defined by the user but constrained by the inferred type. For instance, a custom field with the expression AVG(field) will always return a numeric value. For more information, see Custom fields Expression Editor functions.

Field Type Description Example

Measure

The field contains a Number as value.

My Measure

My Measure CF

Dimension

The field contains a String as value.

My Dimension

My Dimension CF

Date

The field contains a Date as value.

UA My Date

UA My Date CF

Boolean

The field contains a Boolean as value.

UA My Boolean

Create a custom field

Operators

Functions

Edit a custom field

Remove a custom field from a report