name: op-win-lag
description: Per-row value of the field from N rows earlier in the ordered partition.
kind: operator
category: WIN
operator: WIN_LAG
type: reference
applies_to: process, compose, predict
examples_tags: [time-series, window-operator, buffered-pipeline]
Window operators emit row-level values; they do not produce Response.Components.
Use when
Adds to every row the value of a field from a set number of rows earlier in the ordered series, such as last month’s sales.
Questions it answers:
- What were each store’s sales in the month before, on the same row as this month’s?
- What score did each respondent give in the previous wave?
Use something else:
WIN_DELTAwhen you want the difference from the earlier row, not its value.
Params
| Name | Type | Default | Description |
|---|---|---|---|
offset | int | 1 | Lookback distance (≥ 0). |
default | any | — | Substitute when offset crosses partition start; absent: null. Over a categorical: a dictionary label, else PULSE_WINDOW_INVALID default_not_a_label. |
partition_by (carve), order_by (≥1, required, any type but set_* (PULSE_WINDOW_INVALID) or vec_* (PULSE_VECTOR_FIELD_NOT_SCALAR)), frame (forbidden).
Inputs
field — admitted types: see ## Contract.
Output
One value per row written to label (default WIN_LAG_<field>): a verbatim copy, so a u64 id renders its exact word and a categorical its label — a lagged category on the source dictionary. When i - offset < 0 within the partition emits default if set, else null.
Contract
- Types (
field):categorical_*,date,f32,f64,u16,u32,u4,u64,u8; any other scalar type isPULSE_FIELD_TYPE_UNSUPPORTED. - Weight: no weighted form and no slot weight; a request weight is
PROCESSING_CONFIG, an instance default is skipped. - Streaming: buffered only.
Gotchas
order_byrequired,frameforbidden,offset < 0refused —PULSE_WINDOW_INVALIDon predict AND runtime.- Partitioning by the raw
datecollapses each row to its own partition. Pick a coarser partition (region, account) and order by date. - Regressions, post-window formulas, aggregations and groupers may read the label (
regression-model-options,windows-first). - A lagged category is a
GROUP_CATEGORYkey (group or crosstab axis) or another lag’s field ONLY; any other read isPULSE_FIELD_TYPE_UNSUPPORTED.materializestores it as the source’s categorical.
See
pulse_examples_search tags=[time-series]- Skills:
window-design,op-win-lead,op-win-pct-change