> 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/pivot.md).

# Pivot

> Turn the values of one column into columns.

Turns the distinct values of `columns` into columns of their own, filling each cell by aggregating `values` with `fn`, keyed by `index`.

## At a glance

|                          |                        |
| ------------------------ | ---------------------- |
| Module type              | `Pivot`                |
| 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

### `values`

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

The column aggregated into each cell.

### `columns`

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

The column whose distinct values become columns.

### `fn`

`"sum" | "avg" | "min" | "max" | "count" | "countDistinct" | "median" | "first" | "last"` · required · defaults to `"sum"`

How several values landing in one cell are combined.

### `index`

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

The columns that stay as rows.

## 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` | One row per `index` combination, one column per distinct value found. |

***

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