# Create a Pivot Table

### Overview

This procedure generates a pivot table from an existing table based on specified criteria. Using a pivot table is a way to quickly summarize large amounts of data.

### Input Concepts

| Concept                 | Type      | Description                                                                                                              | Default    | Required |
| ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ | ---------- | -------- |
| `table`                 | `table`   | The original table from which the pivot table will be created.                                                           | No default | Yes      |
| `row fields`            | `strings` | The columns to use as the **indexes** of the pivot table.                                                                | No default | Yes      |
| `column field`          | `string`  | The column to use as the **columns** of the pivot table.                                                                 | No default | Yes      |
| `value field`           | `string`  | The column to use as the **values** of the pivot table.                                                                  | No default | Yes      |
| `aggregation function`  | `string`  | The function to aggregate the values in the pivot table. Valid options are `sum`, `mean`, and `count`.                   | No default | Yes      |
| `aggregate column name` | string    | The column name for the aggregated result in columns and row. Specified as: `the aggregate column name is "column name"` | No default | No       |

### Output Concepts

| Concept       | Description                |
| ------------- | -------------------------- |
| `pivot table` | The generated pivot table. |

### Examples

#### 1. Example 1

For example, say we have a table defined in our automation as `the sales data table`.

| Region | Product  | Sales |
| ------ | -------- | ----- |
| North  | Widget A | 100   |
| South  | Widget B | 250   |
| East   | Widget A | 300   |
| West   | Widget B | 450   |

{% tabs %}
{% tab title="Automation" %}

```
the file
open the sales data table at the file
create a pivot table from the sales data table with
  the row fields are "Region"
  the column field is "Product"
  the value field is "Sales"
  the aggregation function is "sum"
  the aggregate column name is "Sales"
```

{% endtab %}

{% tab title="Results" %}

| Region        | Widget A | Widget B | Sales |
| ------------- | -------- | -------- | ----- |
| East          | 300      | 0        | 300   |
| North         | 100      | 0        | 100   |
| South         | 0        | 250      | 250   |
| West          | 0        | 450      | 450   |
| Sales         | 400      | 700      | 1100  |
| {% endtab %}  |          |          |       |
| {% endtabs %} |          |          |       |
