> For the complete documentation index, see [llms.txt](https://docs.inverse.watch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inverse.watch/user-guide/visualizations/how-to-make-a-pivot-table.md).

# How to Make a Pivot Table

### Intro

The application’s pivot table visualization can aggregate records from a query result into a new tabular display. It’s similar to `PIVOT` or `GROUP BY` statements in SQL. But the visualization is configured with drag-and-drop fields instead of SQL code.

## Step 1: Write a query <a href="#step-1-write-a-query" id="step-1-write-a-query"></a>

It should return at least three columns. The source query for a pivot table is usually non-aggregated or "melted", and not necessarily sorted the way we want.&#x20;

<figure><img src="https://4269815422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGc9mnST31tkU3h2NNgSL%2Fuploads%2Fn0TWvGV7VCTWNjuidufZ%2Fpivot_table_write_a_query.gif?alt=media&amp;token=d58d3164-e048-48f9-bceb-f764ba2e3cdf" alt=""><figcaption></figcaption></figure>

We will use the pivot table to do this without SQL.

## Step 2: Add a **Pivot Table** visualization <a href="#step-2-add-a-pivot-table-visualization" id="step-2-add-a-pivot-table-visualization"></a>

Click **Add Visualization** and choose **Pivot Table** as the visualization type. The visualization preview on the right will update to show a pivot table.

All the field aliases from your query result become available at the top of the pivot control surface. You can drag these to the *row* side or the *column* side. You can also nest them.

Here is a simple example using the data from the above query:

<figure><img src="https://4269815422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGc9mnST31tkU3h2NNgSL%2Fuploads%2FfhOL7pwdTm56iq0y4Lt4%2Fpivot_table_bis.gif?alt=media&amp;token=c47d1155-3a56-4444-bf22-1c88b45d5981" alt=""><figcaption><p>pivot table</p></figcaption></figure>

{% hint style="warning" %}
Pivot table performance can degrade if your query result is too big. The exact size threshold will depend on the computer and browser from which you access the application. But in general, performance is best below 50,000 *fields*. That could mean 10,000 records with 5 fields each. Or 1,000 records with 50 fields each.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.inverse.watch/user-guide/visualizations/how-to-make-a-pivot-table.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
