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

# pivot_table

> **Pivot table**

Build a pivot over a table or worksheet: row dimensions down the side, column dimensions across the top, measures in each cell, with subtotals and totals; aggregate_table runs a flat group-by. Works on worksheets and customDataTables only. Results are not paginated: a query over 10000 intermediate groups fails rather than returning partial cells; `rowTopN` and `columnTopN` trim the returned groups, not the query.

`layout` lists the dimensions, measures and the `columnGroups` kept after `columnTopN`; `layout.columnGroupsTruncated` and `rowsTruncated` flag trimmed axes. Each record has a `level` (`cell`, `rowSubtotal`, `columnTotal` or `grandTotal`), `row` and `column` maps of the dimension values held fixed, keyed by dimension alias, and `values` keyed by measure alias. Records are sparse: a missing intersection means no data, not zero. Totals cover the full filtered dataset, so when groups are trimmed the visible cells do not sum to them. Dimension values group as stored, without case or whitespace merging. singleSelect and bucketed values come back as option ids (`opt_*`) with no label map; describe_column lists each id's label.



## OpenAPI

````yaml /api-reference/tools-openapi.json post /v1/pivot_table
openapi: 3.1.0
info:
  title: Rippit API
  version: 1.0.0
  description: Every operation is also an MCP tool with the same name and parameters.
servers:
  - url: https://api.rippit.com
security:
  - bearer: []
paths:
  /v1/pivot_table:
    post:
      summary: pivot_table
      description: >-
        **Pivot table**


        Build a pivot over a table or worksheet: row dimensions down the side,
        column dimensions across the top, measures in each cell, with subtotals
        and totals; aggregate_table runs a flat group-by. Works on worksheets
        and customDataTables only. Results are not paginated: a query over 10000
        intermediate groups fails rather than returning partial cells; `rowTopN`
        and `columnTopN` trim the returned groups, not the query.


        `layout` lists the dimensions, measures and the `columnGroups` kept
        after `columnTopN`; `layout.columnGroupsTruncated` and `rowsTruncated`
        flag trimmed axes. Each record has a `level` (`cell`, `rowSubtotal`,
        `columnTotal` or `grandTotal`), `row` and `column` maps of the dimension
        values held fixed, keyed by dimension alias, and `values` keyed by
        measure alias. Records are sparse: a missing intersection means no data,
        not zero. Totals cover the full filtered dataset, so when groups are
        trimmed the visible cells do not sum to them. Dimension values group as
        stored, without case or whitespace merging. singleSelect and bucketed
        values come back as option ids (`opt_*`) with no label map;
        describe_column lists each id's label.
      operationId: pivot_table
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                tableId:
                  type: string
                  minLength: 1
                  pattern: ^[A-Za-z0-9_-]+$
                  description: Data table or worksheet id.
                rowDimensions:
                  minItems: 1
                  maxItems: 5
                  type: array
                  items:
                    type: object
                    properties:
                      columnId:
                        type: string
                        minLength: 1
                        description: Column id, not its label.
                      dateTrunc:
                        description: >-
                          Date grain; the alias becomes
                          `<columnId>_<dateTrunc>`.
                        type: string
                        enum:
                          - minute
                          - hour
                          - day
                          - week
                          - month
                          - year
                    required:
                      - columnId
                    additionalProperties: false
                  description: >-
                    Row hierarchy, top level first; subtotals return at every
                    level.
                columnDimensions:
                  description: >-
                    Each value combination becomes a column group; omit for row
                    subtotals only.
                  maxItems: 3
                  type: array
                  items:
                    type: object
                    properties:
                      columnId:
                        type: string
                        minLength: 1
                        description: Column id, not its label.
                      dateTrunc:
                        description: >-
                          Date grain; the alias becomes
                          `<columnId>_<dateTrunc>`.
                        type: string
                        enum:
                          - minute
                          - hour
                          - day
                          - week
                          - month
                          - year
                    required:
                      - columnId
                    additionalProperties: false
                measures:
                  minItems: 1
                  maxItems: 10
                  type: array
                  items:
                    type: object
                    properties:
                      columnId:
                        type: string
                        minLength: 1
                        description: Column id, not its label.
                      agg:
                        type: string
                        enum:
                          - count
                          - count_distinct
                          - sum
                          - avg
                          - min
                          - max
                      alias:
                        description: Key under `values`; defaults to `<columnId>_<agg>`.
                        type: string
                        minLength: 1
                    required:
                      - columnId
                      - agg
                    additionalProperties: false
                where:
                  description: Filters source rows before pivoting.
                  maxItems: 20
                  type: array
                  items:
                    $ref: '#/components/schemas/pivot_table____schema0'
                arrayExpansions:
                  description: >-
                    Explode array columns into one row per element, referenced
                    by alias; empty arrays yield no rows, and counts describe
                    elements, not records.
                  maxItems: 3
                  type: array
                  items:
                    type: object
                    properties:
                      columnId:
                        type: string
                        minLength: 1
                        description: Array column id.
                      alias:
                        type: string
                        pattern: ^[A-Za-z][A-Za-z0-9_]*$
                        description: Unused column id for the elements.
                    required:
                      - columnId
                      - alias
                    additionalProperties: false
                sort:
                  description: Defaults to the first measure, descending.
                  type: object
                  properties:
                    alias:
                      type: string
                      minLength: 1
                      description: >-
                        A measure alias ranks row groups by their total across
                        columns; a row-dimension column id orders each level by
                        label.
                    direction:
                      description: Defaults to desc for a measure, asc for a dimension.
                      type: string
                      enum:
                        - asc
                        - desc
                  required:
                    - alias
                  additionalProperties: false
                columnTopN:
                  description: >-
                    Keeps the top column groups by the first measure's total;
                    defaults to 10.
                  type: integer
                  minimum: 1
                  maximum: 50
                rowTopN:
                  description: >-
                    Keeps the top-level row groups ranked first by `sort`;
                    omitted, up to 500 row groups return.
                  type: integer
                  minimum: 1
                  maximum: 500
              required:
                - tableId
                - rowDimensions
                - measures
              additionalProperties: false
      responses:
        '200':
          description: Tool result.
components:
  schemas:
    pivot_table____schema0:
      anyOf:
        - type: object
          properties:
            columnId:
              type: string
              minLength: 1
              description: Column id, not its label.
            operator:
              type: string
              enum:
                - '='
                - '!='
                - '>'
                - <
                - '>='
                - <=
                - IN
                - NOT IN
                - LIKE
                - CONTAINS_ALL
                - ANY
                - ALL
                - NONE
                - NOT_EMPTY
                - EMPTY
                - IS
                - IS NOT
              description: >-
                IN/NOT IN match exact values or array elements; CONTAINS_ALL
                needs all. ANY/ALL/NONE: case-insensitive substring matches,
                never for id columns (they over-match).
            value:
              description: >-
                Array for multi-value operators (ANY/ALL/NONE: at most 250
                strings). singleSelect and bucketed columns store option ids
                (opt_*): filter by id; a label matches no rows. describe_column
                with `search` resolves a label to its id.
              anyOf:
                - type:
                    - string
                    - number
                    - boolean
                    - 'null'
                - type: array
                  items:
                    type:
                      - string
                      - number
                      - boolean
                      - 'null'
          required:
            - columnId
            - operator
          additionalProperties: false
        - type: object
          properties:
            columnId:
              type: string
              minLength: 1
              description: Column id, not its label.
            operator:
              type: string
              const: BETWEEN
            date_from:
              type: string
              description: >-
                Inclusive. Plain dates cover whole days, and times without an
                offset are clock times, in the reported timezone or UTC.
            date_to:
              type: string
              description: Inclusive; a plain date covers that whole day.
          required:
            - columnId
            - operator
            - date_from
            - date_to
          additionalProperties: false
        - type: object
          properties:
            columnId:
              type: string
              minLength: 1
              description: Column id, not its label.
            period:
              type: object
              properties:
                'n':
                  type: integer
                  minimum: -9007199254740991
                  maximum: 9007199254740991
                  description: Signed units; negative values reach into the past.
                unit:
                  type: string
                  enum:
                    - hours
                    - days
                    - weeks
                    - months
                    - years
              required:
                - 'n'
                - unit
              additionalProperties: false
              description: >-
                Whole days in the read timezone, including today: { n: -7, unit:
                "days" } keeps today and the six prior days. Months/years follow
                the calendar; hours are exact. Reads re-resolve; worksheets keep
                a snapshot.
            offset:
              description: >-
                Shifts the anchor before period applies; { n: -1, unit: "weeks"
                } moves it one week into the past.
              type: object
              properties:
                'n':
                  type: integer
                  minimum: -9007199254740991
                  maximum: 9007199254740991
                  description: Signed units; negative values reach into the past.
                unit:
                  type: string
                  enum:
                    - hours
                    - days
                    - weeks
                    - months
                    - years
              required:
                - 'n'
                - unit
              additionalProperties: false
          required:
            - columnId
            - period
          additionalProperties: false
        - type: object
          properties:
            or_filters:
              minItems: 1
              type: array
              items:
                minItems: 1
                type: array
                items:
                  $ref: '#/components/schemas/pivot_table____schema0'
              description: ORs branches of ANDed items.
          required:
            - or_filters
          additionalProperties: false
  securitySchemes:
    bearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.