Berserk Docs
Scalar FunctionsOther Functions

prev

Returns the value of a column from a row at a given offset before the current row in a serialized row set. A row set is serialized by the sort, top, top-hitters, or serialize operators; order-preserving operators (extend, project, where, ...) keep that property. Only valid in a serialized context.

Syntax

prev(column, offset, default_value)

Parameters

Prop

Type

Returns: dynamic

Examples

Example 1

datatable(value:long)[
  1,
  2,
  3,
  4
]
| sort by value asc
| extend prev_value = prev(value)
value (long)prev_value (long)
1null
21
32
43

Example 2

datatable(value:long)[
  1,
  2,
  3,
  4
]
| sort by value asc
| extend prev_value = prev(value, 2, 0)
value (long)prev_value (long)
10
20
31
42

On this page