# next > AQL Window Function: A window function that returns the value of the next row at an offset relative to the current row. :::tip Knowledge Checkpoint Readings that will help you understand this documentation better: - [Window Functions Overview](/reference/aql/window-function) ::: ## Definition A window function that returns the value of the next row at an offset relative to the current row. **Syntax** ```aml next(expr, offset, order: order_expr, ...) next(expr, offset, order: order_expr, ...) next(expr, offset, order: order_expr, ..., reset: partition_expr, ...) next(expr, offset, order: order_expr, ..., partition: partition_expr, ...) ``` ```aml title="Examples" next(count(users.id), order: count(users.id) | desc()) next(count(users.id), 2, order: users.created_at | month()) next(count(users.id), 4, order: users.created_at | month(), reset: users.gender) // Axis-aware examples next(revenue, order: 'rows') // Next row value next(revenue, 2, order: 'columns', partition: 'rows') // Two columns ahead within each row next(sales, order: 'x_axis' | desc()) // Next value in reverse order ``` **Input** - `expr` (**required**): An expression of the value - `offset` (**optional**): The offset of the next row relative to the current row. If not specified, the default value is 1. - `order` (**required**, **repeatable**): A field that is used for ordering. The order defaults to ascending. The order can be set explicitly with `asc()` or `desc()`. You can also use [axis references](/reference/aql/window-function#axis-aware-window-functions): - `'rows'` or `'x_axis'`: Order by dimensions mapped to rows/x-axis - `'columns'` or `'legend'`: Order by dimensions mapped to columns/legend - Axis references can be modified with `asc()` or `desc()`: `order: 'rows' | desc()` :::warning If the specified order does not uniquely identify rows, the result of the function can be non-deterministic. For example, if you use `order: users.age`, and there are multiple users with the same age in the same partition, the result can be unexpected. ::: - `partition` or `reset` (**repeatable**, **optional**): A field that is used for partitioning the table. You can also use [axis references](/reference/aql/window-function#axis-aware-window-functions) like `'rows'`, `'columns'`, `'x_axis'`, or `'legend'`. If partitions are not specified: - If `order` is specified, the table will be partitioned by all other grouping columns. - If `order` is not specified, the table will be considered as a single partition. **Output** The value of the next row in a offset relative to the current row. ## Sample Usages Please refer to the sample usages in [previous](/reference/aql/previous#sample-usages). ## See also - [`previous()`](/reference/aql/previous) - [`first_value()`](/reference/aql/first_value) - [`last_value()`](/reference/aql/last_value) - [Window Functions](/reference/aql/window-function)