Skip to content

Window columns

Window columns are extra, read-only measure columns the engine derives by looking across a node’s siblings: a cumulative running total, a 1-based rank, a share of the total or of the parent, a delta versus the previous sibling, or a trailing moving average. They are declared, not hand-computed — the engine (or the parity-verified core port) does the math, and each appears as one more column after your base measures.

This is best seen in a running app; the derived columns append to the same roll-up tree. The declarative config is the star here:

from dash_tensor_grid import TensorGrid, build_grid
payload = build_grid(sales, {
"rows": ["region", "country"],
"measures": {"revenue": "sum"},
"formats": {"revenue": "currency:USD"},
"window_columns": [
{"kind": "running_total", "by": "revenue", "as": "cum", "format": "currency:USD"},
{"kind": "rank", "by": "revenue", "as": "rev_rank"},
{"kind": "pct_of_total", "by": "revenue"}, # -> revenue_pct (percentage:1)
{"kind": "pct_of_parent", "by": "revenue"}, # -> revenue_pct_parent
{"kind": "delta", "by": "revenue"}, # change vs previous sibling
{"kind": "ma", "by": "revenue", "window": 3}, # trailing 3-period average
],
})
TensorGrid(id="grid", row_data=payload["row_data"], column_defs=payload["column_defs"])
  • kind — one of running_total, rank, pct_of_total, pct_of_parent, delta, ma (Dash config, matched case- and underscore-insensitively) / runningTotal, rank, pctOfTotal, pctOfParent, delta, movingAverage (JS adapters).
  • by is the base measure to derive from; as names the derived column (each kind has a sensible default key when omitted in the config).
  • rank takes descending (default true) and dense; delta takes percent: true for a percent change; ma / movingAverage takes window (default 3).
  • Percent kinds store a fraction in [0, 1]. In the Dash config they default to percentage:1; in the JS adapters give a % number format ('0.0%').
  • Window columns apply to the row tree only — they are refused on a pivot config. Pair them with a top-N roll-up to rank-and-cap in one pass.