Skip to content

Rows, Columns and Values

A Pivot table answers a question by grouping records and calculating a summary. For sales by region and quarter, the three choices are:

ChoiceExampleWhat appears
RowsRegionNorth, South and West down the left
ColumnsQuarterQ1 and Q2 across the top
ValuesSum of SalesSales total at each intersection
Interactive example

Rows, columns and values

Rows group regions, columns compare quarters, and values add up sales.

Try it: Switch the row grouping to products.

The example loads when visible.

What to notice: The same orders answer a different question.

TypeScript source

Use this code in your app after installing the packages described in this guide.

first-table.ts
import { defineCustomElements } from '@revolist/revogrid/loader';
import { PivotPlugin } from '@revolist/pivot';
import { orders, salesReport } from './sales-data';
import '@revolist/revogrid-pro/dist/revogrid-pro.css';
import '@revolist/pivot/styles.css';
// Register the grid once in your application.
defineCustomElements();
await customElements.whenDefined('revo-grid');
export const grid = document.createElement('revo-grid');
grid.style.height = '280px';
grid.plugins = [PivotPlugin];
grid.pivot = salesReport;
grid.source = orders;
document.body.append(grid);
Download first-table.ts

Changing a row or column field changes how the same records are grouped. It does not edit the records. Adding a second row field creates nested groups; for example, Region → Product.

import type { PivotConfig } from '@revolist/pivot';
const config: Partial<PivotConfig> = {
rows: ['region'],
columns: ['quarter'],
values: [{ prop: 'sales', aggregator: 'sum', label: 'Sales' }],
};

The strings are property names in your source records. A dimension is the reusable metadata for one of those fields; it can provide a friendly name, available aggregations and formatting.

The North/Q1 cell adds the sales values of all records whose region is North and quarter is Q1. Grand Total summarizes the whole selected dataset. Totals and averages explain why an average total is calculated from records rather than averaged from visible cells.

Prepare your data, then create your first Pivot. To change fields through the interface, use the field panel or configurator. The same fields become chart categories and series.