> For the complete documentation index, see [llms.txt](https://docs.fabricplan.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fabricplan.com/planning-sheets/how-tos/infobridge/data-transformations/pivot-columns-unpivot-columns.md).

# Pivot and unpivot columns

Use the **Pivot Column** and **Unpivot Column** transformations in Infobridge to reorganize data into formats that are easier to analyze and report on.

Pivoting converts values from a selected column into multiple columns, while unpivoting converts multiple columns back into rows.

### Pivot column

The **Pivot Column** transformation converts values from a selected dimension into separate columns. This transformation lets you compare measures across categories more effectively.

#### Example: Pivot segment sales data

The following example shows sales data in a tabular format, where each segment appears as a row.

| Country | Segment          | Sales   |
| ------- | ---------------- | ------- |
| Canada  | Channel Partners | 491.16K |
| Canada  | Enterprise       | 3.97M   |
| Canada  | Government       | 10.74M  |
| Canada  | Midmarket        | 510.21K |
| Canada  | Small Business   | 9.18M   |
| France  | Channel Partners | 372.09K |
| France  | Enterprise       | 3.89M   |
| France  | Government       | 12.13M  |
| France  | Midmarket        | 593.80K |
| France  | Small Business   | 7.37M   |

After you pivot the **Segment** column, each segment value appears as a separate column.

| Country                  | Enterprise | Government | Midmarket | Small Business | Channel Partners |
| ------------------------ | ---------- | ---------- | --------- | -------------- | ---------------- |
| Canada                   | 3.97M      | 10.74M     | 510.21K   | 9.18M          | 491.16K          |
| France                   | 3.89M      | 12.13M     | 593.80K   | 7.37M          | 372.09K          |
| Germany                  | 4.09M      | 11.45M     | 301.34K   | 7.33M          | 336.43K          |
| Mexico                   | 3.32M      | 9.79M      | 511.14K   | 7.10M          | 234.38K          |
| United States of America | 4.35M      | 8.39M      | 465.39K   | 11.46M         | 366.53K          |

#### Create a pivot column

The following procedure pivots the **Segment** column and aggregates values from the **Sum of Sales** measure.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FrSM6mxwkrxiTUYTz2KVw%2Fpivot-column-source-data.png?alt=media&amp;token=4e028077-4039-4c7c-9c14-232814ff3c3e" alt=""><figcaption></figcaption></figure>

1. On the **Transform** tab, select **Pivot Column**.
2. In **Category**, select **Segment**.
3. In **Operations**, select the aggregation type.
4. In **Values**, select **Sum of Sales**.
5. Select **Apply**.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FHpaC5M957VASYqV3uImq%2Fpivot-column-configuration.png?alt=media&amp;token=49b83901-e33c-4575-a2ee-ac8aaa82bbfb" alt=""><figcaption></figcaption></figure>

After you apply the transformation, each segment value becomes a separate column.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FiwYO62HcwHILI4P6YqKZ%2Fpivot-column-results.png?alt=media&amp;token=92ef100f-8f88-434c-9ac9-37def39dc725" alt=""><figcaption></figcaption></figure>

#### Choose an aggregation type

The **Operations** field determines how to aggregate values when multiple records exist for the same combination of dimensions.

Available aggregation options include:

* Sum
* Average
* Minimum
* Maximum

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FdN5IxBlXxMbYjwOXNfJH%2Fpivot-column-aggregation-options.png?alt=media&amp;token=57a92958-2505-46b7-8930-9891245281a8" alt=""><figcaption></figcaption></figure>

### Unpivot column

The **Unpivot Column** transformation reverses a pivot operation by converting multiple columns into rows.

#### Select columns to unpivot

For example, after pivoting the **Segment** column, each segment exists as an individual column. Unpivoting converts those segment columns back into row values.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2Fs4ACB8cRY0zB3HxKfR7e%2Funpivot-column-source-data.png?alt=media&amp;token=85f18b61-806f-4b52-8d70-76061d688266" alt=""><figcaption></figcaption></figure>

1. On the **Transform** tab, select **Unpivot Column**.
2. In **Category**, select the columns to convert into rows.
3. Select **Apply**.

The following example selects all segment columns.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FslEUAcR2V5v9m9V0Yy4H%2Funpivot-column-configuration.png?alt=media&amp;token=760c2ac0-5ded-4d74-9f9d-a99aac267a99" alt=""><figcaption></figcaption></figure>

After you apply the transformation, the selected columns become two new columns:

* **Attribute**: Contains the original column names.
* **Value**: Contains the corresponding measure values.

For example, segment names such as Enterprise, Government, and Small Business move into the **Attribute** column, and their corresponding sales values appear in the **Value** column.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FP7z1QcMI9CfXuw4IFmaB%2Funpivot-column-results.png?alt=media&amp;token=5e489a97-d50f-4a40-b274-ed4f8cf65ec7" alt=""><figcaption></figcaption></figure>

### Rename unpivoted columns

After unpivoting, the generated **Attribute** and **Value** column names might not match your business terminology.

Use **Rename Column** to replace the default column names with names that better reflect your business data.

1. On the **Transform** tab, select **Rename Column**.
2. Select the column to rename.
3. Enter a new column name.
4. Select **Apply**.

The following example renames the **Value** column to **Sales**.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FfWVPDfZTlpF81qAw23KP%2Frename-unpivoted-column.png?alt=media&amp;token=3826068d-8a82-46ff-8709-508123b053a5" alt=""><figcaption></figcaption></figure>

After you apply the rename operation, the column displays the updated name.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2F4vwoQRZtchCe5UlZAxqM%2Frenamed-sales-column.png?alt=media&amp;token=98fd3a47-eed0-42e8-b43f-8a797ee94079" alt=""><figcaption></figcaption></figure>

You can use the renamed column in subsequent transformations, calculations, and reporting scenarios.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fabricplan.com/planning-sheets/how-tos/infobridge/data-transformations/pivot-columns-unpivot-columns.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
