← ClaudeAtlas

dax-window-functionslisted

Use when writing a DAX window function — WINDOW, OFFSET, INDEX, RANK, ROWNUMBER, MOVINGAVERAGE, RUNNINGSUM with ORDERBY/PARTITIONBY/MATCHBY — for rolling and trailing averages, running totals, prior-row or prior-year comparisons, or ranking within a partition. Covers ABS vs REL positioning, the ALLSELECTED relation default that silently returns blanks, and MATCHBY for fact tables. Triggers on "rolling average", "running total", "trailing N", "OFFSET returns blank", "ABS vs REL", "PARTITIONBY".
CSalcedoDataBI/dax-for-agents · ★ 0 · AI & Automation · score 68
Install: claude install-skill CSalcedoDataBI/dax-for-agents
# DAX Window Functions — the navigation machinery ## Overview The `WINDOW` family operates over a **relation** (a virtual table), not scalars: it is evaluated in the current filter context, **partitioned**, **sorted**, then **navigated** relative to the current row. This is the machinery inside rolling/trailing UDFs — see **`dax-udf-authoring`**. **Per-function reference:** **`dax-reference`** carries each function's signature, return type and where it is legal. This skill is the working summary of how the family behaves together, plus the gotchas that bite. ## Pick the function | Need | Function | Returns | |---|---|---| | Contiguous set of rows (rolling/trailing window) | `WINDOW` | table | | Single row at a relative offset (prior/next, YoY) | `OFFSET` | row(s) | | Single row at an absolute position (first/last) | `INDEX` | row | | Rank within partition (ties allowed) | `RANK` | scalar | | Unique row number (no ties) | `ROWNUMBER` | scalar | | Moving avg / running sum **(visual calc ONLY)** | `MOVINGAVERAGE` / `RUNNINGSUM` | scalar | Table-returning ones (`WINDOW/OFFSET/INDEX`) are wrapped in an aggregator (`AVERAGEX`, `SUMX`) or used as a `CALCULATE` filter. ## Shared positional tail (order is FIXED) ``` [, <relation>/<axis>][, <orderBy>][, <blanks>][, <partitionBy>][, <matchBy>][, <reset>] ``` Skip `relation` but keep `orderBy`: leave the slot empty → `OFFSET(-1, , ORDERBY(...))`. ## ABS vs REL — the crux of WINDOW - **REL (relative):** offset from the **current