> For the complete documentation index, see [llms.txt](https://docs.smaq.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smaq.io/documentation/features/dashboard/pivot-table.md).

# Pivot Table

This guide explains how to create pivot tables in the platform. You can do it in two ways:

1. By choosing the chart type for a visualization to be ‘Pivot Table’ inside the Chart tab of visualization setting.
2. By using the pivot option inside the Aggregate tab of visualization setting.

| **Feature**   | **Method 1: Chart Type**                             | **Method 2: Aggregate Tab**                    |
| ------------- | ---------------------------------------------------- | ---------------------------------------------- |
| **Best For**  | Multi-level/nested rows (e.g., Campaign > Ad Group). | Custom grouping (AI, Patterns, or Word Match). |
| **Row Limit** | Multiple dimensions (nested).                        | Exactly one dimension.                         |
| **Location**  | **Chart** tab → Pivot Table.                         | **Aggregate** tab → Pivot.                     |

### **Create a pivot table by choosing the Pivot Table chart type**

Use this when you want a **multi-level row structure** (e.g. campaigns with ad groups underneath), and when you don’t require custom grouping or extra aggregation as the chart only changes how the same data is displayed; it does not create new aggregated rows.

#### Prerequisite:

* At least **2 dimensions** selected in the **Data** tab (e.g. Campaign + Ad group).

If you select only 1 dimension, the option for Pivot Table as chart type will not appear in the chart tab

#### Steps to Create a Pivot Table

1. Set up your data:

   * Open the visualization settings of a custom datablock.
   * Add at least 2 dimensions (e.g. Campaign, Ad group) and the metrics you need (e.g. clicks, impressions), and fetch the data.

   <figure><img src="/files/sDfkfPvLpK664xFEFwAA" alt=""><figcaption></figcaption></figure>
2. Switch to Pivot Table:

   * Go to the Chart tab, select Pivot Table as the chart type

   <figure><img src="/files/LQUGcLSP1ESxafTvV0Qc" alt=""><figcaption></figcaption></figure>
3. Configure the Pivot Table:

   In the same Chart Tab you’ll see the pivot settings:

   * Pivot Rows:

     * Use the dropdown “Add row dimension” to one or more dimensions as pivot rows to group your data vertically.
     * The first dimension is the top-level group; each extra dimension nests under the previous, each unique value in your dimension creates a new row.

     <figure><img src="/files/AjhdwuKMt7S1n2L3rCjy" alt=""><figcaption></figcaption></figure>
   * Pivot Column:

     * Chose one dimensions whose unique values become columns (e.g. if “Month” is selected, each month becomes a column).
     * Choose “None” if you only want rows and no column pivot.

     <figure><img src="/files/GpYG5oot1ZsbPqzo6Jur" alt=""><figcaption></figcaption></figure>
   * Metric Aggregations:

     By default, all metric aggregations are set to SUM, but you can customize this to change how your data is summarized.

     * Click the **"Add Metric Aggregation"** button.
     * **Select the Metric:** Choose the specific field you want to modify from the dropdown.
     * **Choose the Rule:** Select your preferred calculation (Sum, Average, Count, Count Distinct, Weighted Average).
     * **Label (Optional):** Enter a custom name for the column header.

     <figure><img src="/files/j1EtcfKDDcp6CPUe2TcK" alt=""><figcaption></figcaption></figure>
4. Optional Display Options:

   Customize your table's layout with these optional totals to make your data easier to scan:

   * **Show row subtotals for outer most row group** Adds a summary row below each major group, for seeing totals for specific categories (like a single Region or Campaign) at a glance.
   * **Show Grand Total:** Adds a final row at the very bottom of your table that calculates the total metric for your entire dataset.

   <figure><img src="/files/2SKd4d44nWACXDnpdLlG" alt=""><figcaption></figcaption></figure>

### **Create a pivot table using the pivot function in aggregation**

Use this when you need exactly one dimension to group your data or when you need **custom grouping** (rules, patterns or word match).

#### Steps to Pivot Data:

1. Ensure you have data:

   * Fetch data from the data tab of the visualization settings so the visualization has rows and columns.

   <figure><img src="/files/vVCfohr6klqptTUPw1mg" alt=""><figcaption></figcaption></figure>
2. Set up aggregation:
   * Go to the **Aggregate** tab in the visualization settings and click **Add**.
   * Dimension (Group by):

     * First select a dimension you want to group your data by.
     * You can optionally create rules to transform or map the selected dimension’s values into groups in three ways - Word Match, Pattern or AI.

     <figure><img src="/files/oSsrVKQzErNCTGARxgMM" alt=""><figcaption></figcaption></figure>
   * Pivot Column:

     * Select a dimension from the dropdown, each of the unique value from the selected dimension will become a column
     * If you set a pivot column, you can set **Footer aggregation for pivot columns** (Sum, Average, Min, Max). This adds a footer row that aggregates across the pivoted columns (e.g. total per row).

     <figure><img src="/files/0uNbf0ky7eBuNaTDcIxg" alt=""><figcaption></figcaption></figure>
