Study FAQ
What must I define before using WINDOW for a rolling DAX calculation?
Also asked as 2
- How do I make a DAX WINDOW calculation deterministic?
- What ordering and partition rules does a DAX rolling window need?
Answer
Define the input relation, independent partitions, deterministic ordering, and the window boundaries before using WINDOW. Also specify whether the calculation means a number of rows or an actual calendar interval; these aren't interchangeable.
WINDOW returns rows in an interval, which an aggregation such as SUMX or AVERAGEX can consume. Relative boundaries are positions around the current row; absolute boundaries are positions within the partition. For a product-specific running result, partition by product and order by a stable date or sequence at the required grain.
Check these conditions:
- Can the ordering and partition keys identify rows uniquely? If not, define a meaningful tie-breaker or matching key.
- Should the window respect the selected set or include periods outside the visible selection?
- Does a missing date mean no row, a zero value, or an invalid period?
- What should happen at the start of each partition and at totals?
A three-row window over sales dates can mean the last three dates with sales, not three consecutive calendar days. Use a complete Date relation when calendar-day semantics require it. Validate ties, gaps, partition boundaries, selections, and totals with a small ordered dataset before tuning performance.
Full explanation
DP-600: Advanced DAX Patterns for Enterprise Semantic Models
Study guide · DP-600
Read the full explanation