Available:slidingWindow()
v1.174.0
The slidingWindow()
function is available
from version 1.174.0.
The slidingWindow()
function applies an
aggregation to a moving window of a specified number of events
in a sequence. It is useful for calculating metrics over a fixed
number of recent events, allowing for trend analysis and
smoothing of data. For aggregating sliding windows based on time
series span, see slidingTimeWindow()
function.
For more information about sequence functions and combined usage, see Sequence Query Functions.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
current | enum | optional[a] | include | Controls whether to include the current event in the accumulation. |
Valid Values | ||||
exclude | Exclude current event in the accumulation | |||
include | Include current event in the accumulation | |||
function [b] | integer | required | The number of events in each window. | |
Maximum | 1000 | 1000 events | ||
function [c] | array of aggregate functions | required | The aggregator function(s) to apply to each window. It only accepts functions that output a maximum of one single event. | |
[a] Optional parameters use their default value unless explicitly set. |
Note
The
slidingWindow()
function must be used after an aggregator function (for example,head()
,sort()
,bucket()
,groupBy()
timeChart()
) to ensure event ordering, as theaccumulate()
function requires a specific order to calculate cumulative values correctly.Only functions (for example,
sum()
,avg()
,count()
) that output a single event can be used in the sub-aggregation because theslidingWindow()
function needs a single value to add to its running total for each event.
slidingWindow()
Examples
Click
next to an example below to get the full details.Detect Continuously Upwards Going Trend
Detect continuously upwards going trend using the slidingWindow()
function combined with neighbor()