Derived property functions and operators

String functions

  • REGEXEXTRACT (text_property, regular_expression)
    • Description: Extracts substrings matching the regular expression.
    • Example: REGEXEXTRACT("shirt-150", "[0-9]+")
    • Result: 150
  • REGEXREPLACE (text_property, regular_expression, replacement_text)
    • Description: Replaces the property's values with text matching the regular expression with replacement text.
    • Example: REGEXREPLACE("en-US", "-.*", "")
    • Result: en
  • CONCAT(property1, property2)
    • Description: Concatenates a property with another property or text value.
    • Example: CONCAT("firstName", "lastName")
    • Result: firstName lastName
  • LOWERCASE (text_property)
    • Description: Lower cases all characters in property's values.
    • Example: LOWERCASE("John")
    • Result: john
  • UPPERCASE (text_property)
    • Description: Upper cases all characters in property's values.
    • Example: UPPERCASE("John")
    • Result: JOHN
  • SPLIT (property, separator, [index])
    • Description: Split a property based on a delimiter and return an array of split elements. Takes an optional index that returns the element at that index.
    • Example:
      • SPLIT("a_b_c", "_")
      • SPLIT("john@example.com", "@", 0)
    • Result:
      • ["a", "b", "c"]
      • "john"
  • REMOVE (property, text)
    • Description: Remove all occurrence of text in property.
    • Example: REMOVE("en-US", "en-")
    • Result: US
  • EXTRACT_FROM_DICT (property, text)
    • Description: Extract a value from a dictionary string based on a specific key.
    • Example: EXTRACT_FROM_DICT("{'id': 1, 'name': 'John', 'country': 'US'}", "name")
    • Result: John

Math functions

Object functions

Date/ time functions

Amplitude requires all Unix timestamps to be in milliseconds.

Array functions

When performing computations on derived properties created from array properties, Amplitude assumes that only the first child is an array property. Amplitude only considers the first value of the other children, even when those other children are also array properties. Here are some illustrative examples:

plaintext
Example 1  
 propA = [1,2,3], propB = [a,b,c]  
 CONCAT(propA, propB) = [1a, 2a, 3a]  
Example 2  
 propA = [1, 2, 3], propB = [a]  
 CONCAT(propA, propB) = [1a, 2a, 3a]  
Example 3  
 propA = [1], propB = [a, b, c]  
 CONCAT(propA, propB) = [1a]

Property functions

When you select a property from the Insert Property dropdown, Amplitude inserts a property function referencing that property directly into the editor. You can also manually insert this function wherever you want to reference a different Amplitude property.

These functions are available inside other functions.

Reference Event Time

To use an event's timestamp in a derived property formula, select Event Time from the Insert Property dropdown in the derived property builder.

Inside a derived property formula, Event Time is a long value in epoch milliseconds. To display it as a readable date, wrap it in LONG_TO_TIME or LONG_TO_DATE. Don't wrap Event Time in TIME_TO_LONG or DATE_TO_LONG, because the value is already a long and the conversion returns none. To compare Event Time against a date or datetime property, convert the other property to a long with TIME_TO_LONG or DATE_TO_LONG instead.

Conditional operators

String/numerical operators

Set operators

Set literals ("apple", "orange") must appear on the right hand side of the operator.

  • ==
    • Example:
      • IF(product == ("apple","orange"), "true", "false")
      • product = "apple", Returns "true"
  • !=
    • Example:
      • IF(product != ("apple","orange"), "true", "false")
      • product = "banana", Returns "true"

Parallel operators

Perform operations on arrays of data to help perform cart analysis.

Parallel operators require at least one property to be a child cart property, and both properties must be under the same parent property.

For example, products.price and products.quantity are compatible. products.price and shoppinglist.quantity aren't compatible because they have different parent properties.

When you use a parallel operator with two arrays, it adds, multiplies, or compares corresponding values at each position. For example, PARALLEL_SUM([1, 3, 5], [2, 4, 6]) returns [3, 7, 11].

When one input is an array and the other is a scalar (single number), the scalar broadcasts to match the array's length. For example, PARALLEL_SUM([1, 3, 5], 1) returns [2, 4, 6], and PARALLEL_PRODUCT(2, [4, 5, 6]) returns [8, 10, 12].

The derived property that a parallel operator creates becomes a child property of the parent cart property used in the formula. For example, creating a revenue derived property with PARALLEL_PRODUCT(PROPERTY('products.price', 'event'), PROPERTY('products.quantity', 'event')) makes revenue a child property of products.

To use a derived property created with a parallel operator in a chart, first select the parent cart property (marked with {:}). The derived property then appears in the child property selection list.

Parallel operator example

You have a purchase event with the following cart property:

json
"Products": [{
    "brand": "Apple","categories": "Digital Content","department": "Electronics",
    "price": 24.99,"quantity": 1
}, {
    "brand": "Adidas","categories": "Newsletter","department": "Electronics",
    "price": 24.99,"quantity": 1
}, {
    "brand": "Fossil","categories": "Digital Content","department": "Women's Clothing",
    "price": 24.99,"quantity": 2
}]

Use PARALLEL_PRODUCT to create a Revenue derived property:

plaintext
PARALLEL_PRODUCT(
    PROPERTY('Products.price', 'event'), 
    PROPERTY('Products.quantity','event')
)

If you add this property to a chart, group by Brand to view revenue by brand.

You can also use SUM_ARRAY on the Revenue derived property to calculate total cart value:

plaintext
SUM_ARRAY(PROPERTY('Revenue', 'derived'))

This returns the sum of all revenue values across items in the cart, which is useful for filtering or grouping by total cart value.

Was this helpful?

For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.

On this page