> ## Documentation Index
> Fetch the complete documentation index at: https://docs.evidence.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Pivot

> Add a pivot to a table, including date filtering, date grains, formatting, and more

```liquid theme={null}
{% table data="demo.daily_orders" %}
    {% dimension value="category" /%}
    {% pivot value="date" date_grain="year" /%}
    {% measure value="sum(total_sales)" fmt="usd1m" /%}
{% /table %}
```

## Examples

### Pivoted Table

```liquid theme={null}
{% table data="demo.daily_orders" %}
    {% dimension value="category" /%}
    {% pivot value="date" date_grain="year" /%}
    {% measure value="sum(total_sales)" fmt="usd1m" /%}
{% /table %}
```

## Attributes

<ResponseField name="value" type="string" required />

<ResponseField name="fmt" type="string" />

<ResponseField name="date_grain" type="string">
  Bucket dates into a grain. Pass the raw date column as `x` and the chart truncates and groups for you. Temporal grains (`day`, `week`, `month`, `quarter`, `year`, `hour`) preserve the year — use for time-series. Seasonality grains (`day of week`, `day of month`, `day of year`, `week of year`, `month of year`, `quarter of year`) collapse across years — use for cyclical patterns like "which month sells most regardless of year".

  **Allowed values:**

  * `day`
  * `week`
  * `month`
  * `quarter`
  * `year`
  * `hour`
  * `day of week`
  * `day of month`
  * `day of year`
  * `week of year`
  * `month of year`
  * `quarter of year`
</ResponseField>

<ResponseField name="sort" type="string">
  Sort direction for this pivot column. When specified, the table will be sorted by this column.

  **Allowed values:**

  * `asc`
  * `desc`
</ResponseField>

## Allowed Parents

* [table](/components/table)
