# Window calculations > Calculations that look across rows: rank, running total, and moving calculation. Window calculations rank, accumulate, or smooth values across related rows. ## Rank Assigns a rank to each record based on the order of specified fields, optionally within partitions. ### Inputs | Input | Required? | Description | | --- | --- | --- | | Ranking mode | Yes | How ties are numbered:**Rank**: ties share a rank; the next rank skips (e.g. 1, 1, 3, 4, 4, 6, ...).**Dense Rank**: ties share a rank; the next rank is consecutive (e.g. 1, 1, 2, 3, 3, 4, ...). | | Ranking by | Yes | One or more fields to sort by, each ascending or descending. | | Ranking within | No | Restart the ranking within each group (partition). | ### Use cases - Rank products by total sales - Top customers by revenue within each region - Leaderboard of support agents by tickets closed ## Running total Calculates a running sum, average, min, or max of a metric along a date dimension on the viz. **Note:** To run along a non-date dimension, switch to Formula mode and use [`running_total`](/reference/aql/running_total). ### Inputs | Input | Required? | Description | | --- | --- | --- | | Field | Yes | The metric (or dimension) to accumulate along the date dimension on the viz. | | Dimension aggregation | Yes (when Field is a dimension) | How to aggregate the dimension before running (e.g. Count, Sum). | ### Use cases - Cumulative total users over time - Year-to-date revenue by quarter - Running count of orders since launch ## Moving calculations Calculate a moving calculation on a metric. ### Inputs | Input | Required? | Description | | --- | --- | --- | | Moving Calculation | Yes | The function over the window (full list):**Average**: smooth a noisy trend (classic moving average).**Sum**: rolling total over a fixed lookback.**Min** / **Max**: running low or high in the window.**Count**: how many values fall in the window.**Sample standard deviation** / **Population standard deviation**: how spread out values are in the window.**Sample variance** / **Population variance**: squared spread in the window. | | Values | Yes | The metric to compute over the moving window. | | Order values by | Yes | The direction the window slides. Only options that fit the current viz are shown:**Rows**: table; pivot table**Columns**: pivot table**X-Axis**: line chart family, when an X-axis field is on the viz**Legend**: line chart family, when a legend/series field is on the viz**Custom**: pick dimensions to define the move directionTable with more than one dimensionPivot table with more than one row/column dimension | | Number of values | Yes | Window size as **Previous** (behind) and **Next** (ahead), plus the current value:**Trailing** (e.g. Previous 6, Next 0): last N periods including today.**Centered** (e.g. Previous 3, Next 3): look both ways.**Leading** (e.g. Previous 0, Next 6): upcoming values only. | | Null if not enough values | No | What to do when the window is incomplete (start/end of the series):**Checked**: return null until the window is full.**Unchecked**: use a partial window with the values that exist. | ### Use cases - 7-day moving average of orders - Rolling 4-week revenue sum - Moving max of daily active users over the last 14 days