> For the complete documentation index, see [llms.txt](https://docs.rootcause.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rootcause.ai/more-details/applications/application-modules/window.md).

# Window

> A window function over partitions in order: rank, lag, rolling sums.

Runs one window function over rows partitioned by `partitionBy` and ordered by `orderBy`, writing the result to the column named in `as`. `size` is the window length for the rolling functions and the offset for `lag` and `lead`; the ranking functions ignore it.

## At a glance

|                          |                        |
| ------------------------ | ---------------------- |
| Module type              | `Window`               |
| Category                 | Primitives · Dataframe |
| Default tier             | `reactive`             |
| Runs on                  | `reactive`, `durable`  |
| Starts a flow            | no                     |
| Holds a body             | no                     |
| Keeps state between runs | no                     |
| Available in             | every application type |

## Parameters

### `partitionBy`

`string[]` · required · defaults to `[]`

The columns the window restarts on. Empty is one window over the frame.

### `fn`

`"rowNumber" | "rank" | "denseRank" | "lag" | "lead" | "cumSum" | "rollingSum" | "rollingAvg" | "rollingMin" | "rollingMax"` · required · defaults to `"rowNumber"`

The window function: a ranking, an offset, or a running total.

### `as`

`string` · required · defaults to `""`

The column the result is written to.

### `orderBy`

`string[]` · required · defaults to `[]`

The order rows are seen in within a partition.

### `size`

`number | null` · required · defaults to `null`

Window length for the rolling functions, offset for lag and lead; ignored by the rankings.

## Inputs

| Port   | Kind        | Required | Description                                                                                                                           |
| ------ | ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `on`   | `event`     | no       | Implicit on every module that does not itself start a flow: wire an event here to make this module the start of what that event runs. |
| `data` | `dataframe` | yes      | The frame to work on.                                                                                                                 |

## Outputs

| Port     | Kind        | Connects to           | Description                                      |
| -------- | ----------- | --------------------- | ------------------------------------------------ |
| `output` | `dataframe` | `dataframe`, `signal` | The input frame with the window column appended. |

***

[← All application modules](/more-details/applications/application-modules.md)
