Calculated Attributes Reference

Use the following tables and lists to help you define each calculated attribute.

Calculations

The following table lists all supported calculations.

Group Calculation Type Format Example Trigger
Count Count Numeric 123 *synchronous
Aggregation Sum Numeric 123.123 *synchronous
Aggregation Minimum Numeric 123.123 *synchronous
Aggregation Maximum Numeric 123.123 *synchronous
Aggregation Average Numeric 123.123 asynchronous
Aggregation Most frequent Dynamic romance asynchronous
Aggregation Unique values count Numeric 34 asynchronous
Occurrence First value Dynamic comedy asynchronous (until observed)
Occurrence Last value Dynamic action asynchronous
Occurrence First timestamp Timestamp 2020-01-01T22:14:47.1051728Z asynchronous (until observed)
Occurrence Last timestamp Timestamp 2020-01-10T22:14:47.1051728Z *synchronous
List Unique list Comma separated list of dynamic values; maximum of 100. "Item 1","Item 2","Item 3" *synchronous

*Setting the date range to Within the Last causes all calculations to be asynchronous.

Be aware of the following before creating your calculation attributes:

  • Calculated attributes require server-side forwarding. Therefore, this feature isn’t available for kit-only integrations that solely support client-side forwarding.
  • All timestamp values are in ISO 8601 format in the UTC timezone.
  • Several calculations produce results with types that depend on the type of the event attribute selected; for example, First Value` returns a string if the selected event attribute is a string. All attribute values in our platform are stored as strings, including calculated attributes.
  • Calculation speeds listed are after the values have been initialized.
  • For unique lists, up to 100 values are calculated. The values are selected based roughly on the order in which mParticle received the data, though the ordering is not guaranteed. When viewing and using unique lists values (in User activity view, Profile API etc.), values are returned in alphabetical order.
  • When using aliasing to transition from an anonymous to a known user profile, mParticle doesn’t copy the calculated attribute or trigger a recalculation on the resulting profile.
  • For aggregation CAs:

    • More than one attribute may occur the same number of times, creating a tie. To break the tie, mParticle sorts the attribute name alphabetically and chooses the first attribute.
    • After the first 100 values are collected for a Most Frequent or Unique List CA, no more values are collected. For Most Frequent, the frequency of the first 100 are continuously evaluated, but no new values are added. For Unique List, mParticle keeps only the first 100 seen values. To trigger a re-collection of values for either calculation type, edit the CA definition or create a new one.

Calculation date range

The following date ranges in calculated attributes are supported:

  • Within the Last: limit calculations to the period of a specified number of days or weeks ago to now. For example, “most frequent product categories viewed over the last 30 days.”
  • Since: limit calculations to the period of a specified start date to now.

Type conversions

Some calculated attributes, like sum, require numeric event attributes to function. If you select an attribute that is not detected as the correct type, the platform will warn you about using those fields in the calculated attribute definition. You can still use the calculated attribute despite the warning, and it will attempt to convert the string values into numerics. For example, if you pass the attribute amount in as a numeric string like "34.32", a sum calculation will still work correctly: the string "34.32" will be converted to the decimal value 34.32.

Conditions

When you define a calculated attribute, you can add conditional logic. For example, if you wanted to count the total number of times a promotion was clicked, but only for certain currencies, you could add the condition “where the currency code is only AUD or EUR.”

The following conditions are available for all four categories of calculated attributes (Count, Aggregation, Occurrence, and List):

  • Contains
  • Does not Contain
  • Exact Match
  • Does not Match
  • Pattern
  • Exists
  • Not Exists
  • Is Empty
  • Is In List

Commerce quantity fields

The following behaviors affect commerce event attributes (commerce_events) in some calculated attributes:

Product events

The product action (product_action) and product impression (product_impression) attributes can be used in the quantity field for calculations. Note the following behaviors:

  • Average uses the quantity field in a product array when averaging the value of the price field.
  • First value picks the first product in an array if the product attribute is selected.
  • Last value picks the last product in an array if the product attribute is selected.
  • First timestamp is the batch timestamp.
  • Last timestamp is the batch timestamp.
  • Unique list can pick any field in an events or products array.
  • Most frequent uses quantity for calculating the most frequent for non-numeric fields such as brand, category, or coupon code.

Promotion events

The promotion action (promotion_action) attribute can be used in the quantity field for calculations. Note the following behaviors:

  • First value picks the first promotion in a promotions array.
  • Last value picks the last promotion in a promotions array.
  • First timestamp is the batch timestamp.
  • Last timestamp is the batch timestamp.
  • Unique list can pick any field in an events or promotions array.
  • Most frequent can pick any field in an events or promotions array.

Was this page helpful?