Available:partition() v1.174.0

The partition() function is available from version 1.174.0.

The partition() function splits a sequence of events into multiple partitions (subsequences) based on a condition. It allows you to apply a sub-aggregation to each partition separately, useful for grouping related events and performing calculations within these groups, while keeping the order.

For more information about sequence functions and combined usage, see Sequence Query Functions.

ParameterTypeRequiredDefault ValueDescription
conditionboolean expressionrequired   The condition that determines when to split the sequence into new partitions. The condition is provided as a non-aggregate subquery.
function[a]array of aggregate functionsrequired   The aggregator function(s) to apply to each partition.
splitenumoptional[b] before Controls whether the split occurs before or after the event that triggers the condition.
   Valid Values
   afterSplit occurs after the event
   beforeSplit occurs before the event

[a] The parameter name function can be omitted.

[b] Optional parameters use their default value unless explicitly set.

Hide omitted argument names for this function

Show omitted argument names for this function

Events can also be separated by group using the groupBy() function. In that case, the events will be sorted by group, whereas partition() keeps the order of events and splits the groups when the condition is true. An advantage of using partition() is that it, generally, has a lower memory footprint than groupBy().

Note

partition() Examples

Click + next to an example below to get the full details.

Count Events Within Partitions Based on Condition

Count events within partitions based on a specific condition using the partition() function combined with neighbor() and accumulate()

Detect All Occurrences of Event A Before Event B

Detect all occurrences of event A before event B (brute force attack) using the partition() function combined with groupBy()

Detect Event A Happening X Times Before Event B

Detect event A happening X times before event B (brute force attack) using the partition() function combined with groupBy()

Divide Data Into Separate Partitions

Divide data into separate partitions based on a specific condition using the partition() function