---
title: "pivot.insert: Pivot table — Sheet kit command — Kition"
description: "Creates a pivot table from a source range or table (default: around the selection) on a new sheet or at a destination, optionally with rows, columns and values."
canonical: "https://developer.kition.ai/docs/kits/sheet/commands/pivot.insert"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/sheet/commands/pivot.insert](https://developer.kition.ai/docs/kits/sheet/commands/pivot.insert)

# pivot.insert

**Pivot table.** Creates a pivot table from a source range or table (default: around the selection) on a new sheet or at a destination, optionally with rows, columns and values.

- Kit: Sheet 0.1.0 (.xlsx (and opens .xlsm, .xls, .xltx, .csv, .ods, .xlsb)); reference: [Sheet kit commands](https://developer.kition.ai/docs/kits/sheet.md)
- Changes the document: yes

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `columns` | `any[]` | no |  |
| `destination` | `"new" \| "Sheet1!H3"` | no | default: new sheet before the current one, report at A3 |
| `filters` | `any[]` | no | [field] |
| `name` | `string` | no |  |
| `replace` | `boolean` | no |  |
| `rows` | `any[]` | no | [field \| {field, group?: years\|quarters\|months\|days}] |
| `source` | `string` | no | a range in A1 notation such as Sheet1!$A$1:$E$200, or a table name |
| `values` | `any[]` | no | [field \| {field, func?, name?}] |

## Call through sheet_run

```text
sheet_run {
  "path": "<file>.xlsx",
  "steps": [{ "command": "pivot.insert" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `columns`, `destination`, `filters`, `name`, `replace`, `rows`, `source`, `values`. sheet_run answers the step’s result in `completed[i].result`.

## Result

The kit gives no result schema for this command.

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "columns": {
      "items": {},
      "type": "array"
    },
    "destination": {
      "description": "default: new sheet before the current one, report at A3",
      "enum": [
        "new",
        "Sheet1!H3"
      ],
      "type": "string"
    },
    "filters": {
      "description": "[field]",
      "items": {},
      "type": "array"
    },
    "name": {
      "type": "string"
    },
    "replace": {
      "type": "boolean"
    },
    "rows": {
      "description": "[field | {field, group?: years|quarters|months|days}]",
      "items": {},
      "type": "array"
    },
    "source": {
      "description": "a range in A1 notation such as Sheet1!$A$1:$E$200, or a table name",
      "type": "string"
    },
    "values": {
      "description": "[field | {field, func?, name?}]",
      "items": {},
      "type": "array"
    }
  },
  "returns": "{id, name, sheet, anchor, fields}",
  "type": "object"
}
```

Generated from the command list of @kition/sheet-darwin-arm64@0.1.0 and the kit itself (sheet_commands through @kition/cli@0.1.1, built from KitionAI/kition-sheet@82f13b2).
