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"])<TensorGrid data={data} rows={['region', 'country']} measures={{ revenue: 'sum' }} formats={{ revenue: '$0,0' }} windowColumns={[ { kind: 'runningTotal', by: 'revenue', as: 'cum', format: '$0,0' }, { kind: 'rank', by: 'revenue', as: 'rev_rank' }, { kind: 'pctOfTotal', by: 'revenue', as: 'rev_share', format: '0.0%' }, { kind: 'pctOfParent', by: 'revenue', as: 'rev_of_parent', format: '0.0%' }, { kind: 'delta', by: 'revenue', as: 'rev_delta' }, { kind: 'movingAverage', by: 'revenue', as: 'rev_ma3', window: 3 }, ]}/>;<TensorGrid :data="data" :rows="['region', 'country']" :measures="{ revenue: 'sum' }" :formats="{ revenue: '$0,0' }" :window-columns="[ { kind: 'runningTotal', by: 'revenue', as: 'cum', format: '$0,0' }, { kind: 'rank', by: 'revenue', as: 'rev_rank' }, { kind: 'pctOfTotal', by: 'revenue', as: 'rev_share', format: '0.0%' }, { kind: 'delta', by: 'revenue', as: 'rev_delta' }, { kind: 'movingAverage', by: 'revenue', as: 'rev_ma3', window: 3 }, ]"/>mountTensorGrid(el, { data, rows: ['region', 'country'], measures: { revenue: 'sum' }, formats: { revenue: '$0,0' }, windowColumns: [ { kind: 'runningTotal', by: 'revenue', as: 'cum', format: '$0,0' }, { kind: 'rank', by: 'revenue', as: 'rev_rank' }, { kind: 'pctOfTotal', by: 'revenue', as: 'rev_share', format: '0.0%' }, { kind: 'delta', by: 'revenue', as: 'rev_delta' }, { kind: 'movingAverage', by: 'revenue', as: 'rev_ma3', window: 3 }, ],});Options
Section titled “Options”kind— one ofrunning_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).byis the base measure to derive from;asnames the derived column (eachkindhas a sensible default key when omitted in the config).ranktakesdescending(default true) anddense;deltatakespercent: truefor a percent change;ma/movingAveragetakeswindow(default 3).- Percent kinds store a fraction in
[0, 1]. In the Dash config they default topercentage: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.