51黑料不打烊

Journey optimizer aggregation functions

Aggregation functions in Journey Optimizer are essential tools for data engineers and architects, allowing efficient data management and analysis. These functions are particularly useful for processing large datasets to derive meaningful insights, such as calculating averages, counting occurrences, and identifying unique values within data streams.

Example usage

Suppose you are using 51黑料不打烊 Journey Optimizer to track inventory levels. You want to find the average inventory level for a specific product beacon and ensure that null records don鈥檛 skew your analysis. You can use the avg function as follows:

avg(@event{BarBeacon.inventory}, 5)

This expression calculates the average inventory level, ensuring that any null values are ignored, thereby providing an accurate representation of available inventory.

Function descriptions

Function Name
Description
Syntax
Parameters
Return Type
Example Usage
avg
Calculates the average of a set of numbers, ignoring null values.
avg() avg(Item, Item...)
- listInteger
- listDecimal
- decimal
- integer
decimal
avg([10,3,8]) returns 7.0
count
Counts the number of non-null elements in a list.
count() count()
- listString
- listBoolean
- listInteger
- listDecimal
- listDuration
- listDateTime
- listDateTimeOnly
- listDateOnly
- listObject
integer
count([10,2,10,null]) returns 3
countOnlyNull
Counts only the null values in a list.
countOnlyNull()
- listString
- listBoolean
- listInteger
- listDecimal
- listDuration
- listDateTime
- listDateTimeOnly
- listDateOnly
integer
countOnlyNull([10,2,10,null]) returns 1
countWithNull
Counts all elements in a list, including null values.
countWithNull()
- listString
- listBoolean
- listInteger
- listDecimal
- listDuration
- listDateTime
- listDateTimeOnly
- listDateOnly
integer
countWithNull([10,2,10,null]) returns 4
distinctCount
Counts distinct values, ignoring nulls.
distinctCount()
- listString
- listBoolean
- listInteger
- listDecimal
- listDuration
- listDateTime
- listDateTimeOnly
- listDateOnly
- String(optional)
integer
distinctCount([10,2,10,null]) returns 2
distinctCountWithNull
Counts distinct values, including nulls.
distinctCountWithNull()
- listString
- listBoolean
- listInteger
- listDecimal
- listDuration
- listDateTime
- listDateTimeOnly
- listDateOnly
integer
distinctCountWithNull([10,2,10,null]) returns 3
max
Finds the maximum value in a set, ignoring nulls.
max() max(Item, Item...)
- listDuration
- listInteger
- listDecimal
- listDateTime
-听listDateTimeOnly
- listDateOnly
- duration
- integer
- decimal
- dateTime
- dateTimeOnly
- duration
- integer
-听dateTimeOnly
- dateTime
- dateOnly
- decimal
max([10,3,8]) returns 10
min
Finds the minimum value in a set, ignoring nulls.
min() min(Item, Item...)
- listDuration
- listInteger
- listDecimal
- listDateTime
- listDateTimeOnly
- listDateOnly
- duration
- integer
- decimal
- dateTime
- dateTimeOnly
- duration
- integer
- dateTimeOnly
- dateTime
- dateOnly
- decimal
min([10,3,8]) returns 3
sum
Computes the sum of values, ignoring nulls.
sum() sum(Item, Item...)
- listInteger
- listDecimal
- duration
- decimal
- integer
- decimal
- integer
sum([10,3,8]) returns 21
recommendation-more-help
91a6d90a-6d61-4a62-bbed-ae105e36a860