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) |
|---|---|
| 1 | null |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
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) |
|---|---|
| 1 | 0 |
| 2 | 0 |
| 3 | 1 |
| 4 | 2 |