Pivot tables
Use a pivot when you need to cross-tabulate one measure across two categorical fields instead of listing every row.
| Category | EMEA | APAC | AMER | LATAM | Total |
|---|---|---|---|---|---|
| Plan A | 82 | 64 | 45 | 30 | 221 |
| Plan B | 55 | 71 | 38 | 22 | 186 |
| Plan C | 90 | 48 | 60 | 35 | 233 |
| Plan D | 40 | 33 | 52 | 28 | 153 |
| Total | 267 | 216 | 195 | 115 | 793 |
What you can do
pivotlives insideTableSpecalongsidecolumns; when both are present,pivotwins, since the schema has nooneOfbetween them.rowsandcolumnsare each a non-empty array of field names that become the pivot’s row and column axes.valuesholds 1-20PivotValueentries, each afieldplus an optionalagg(sum,avg,min,max,count) that becomes one generated data column per column-axis combination.weightFieldon aPivotValuecomputes a weighted aggregate instead of a plain one;label,format,align,colorScale,cell, andconditionalFormatall apply per value the same as on a regular column.totalsturns onrow,column, and/orgrandsummary rows/columns;maxColumns(1-200, default 50) caps how many generated columns the pivot can produce.
pivot only appears inside a table panel’s spec; there is no pivot equivalent on any chart:* panel.
Spec
View spec
{
"id": "regional-pivot",
"type": "table",
"title": "Revenue by category and region",
"data": {
"rows": [
{
"category": "Hardware",
"region": "West",
"revenue": 420000,
"units": 1200
},
{
"category": "Hardware",
"region": "East",
"revenue": 310000,
"units": 900
},
{
"category": "Software",
"region": "West",
"revenue": 560000,
"units": 2100
},
{
"category": "Software",
"region": "East",
"revenue": 480000,
"units": 1800
}
]
},
"spec": {
"pivot": {
"rows": [
"category"
],
"columns": [
"region"
],
"values": [
{
"field": "revenue",
"agg": "sum",
"weightField": "units",
"format": {
"type": "currency",
"currency": "USD",
"compact": true
}
}
],
"totals": {
"row": true,
"column": true,
"grand": true
},
"maxColumns": 50
}
}
}weightField on the revenue value computes a units-weighted sum instead of a plain sum, and totals adds row, column, and grand summary cells.
Try it live
Open the rich-tables template in the Builder
Open the rich-tables template, page p4-pivot, panel p4-cat-region for a category-by-region pivot, and panel p4-region-quarter for a region-by-quarter one with a colorScale on the values.
Build it in dvt
Every table capability on this site is a few lines of the same declarative JSON spec. Read the full spec format, or connect an AI agent to your warehouse and build one live in the quickstart.
Follow the build
dvt is in founding research. Leave your email and we'll reach out when there's something to see — no newsletters, no noise.