An AG Grid pivot table is a data view that groups records into rows and generates columns from distinct values in selected fields, then summarizes a measure such as sales. To create one, use AG Grid Enterprise, enable pivot mode, assign row-group and pivot columns, and set an aggregation function on the measure column.
What AG Grid Pivoting Does
AG Grid is a JavaScript data-grid library for displaying and interacting with tabular data in web applications. Its pivoting feature reshapes the grid’s view of records: instead of showing one row for every source record, it groups records and displays aggregated results across generated columns. This is useful for exploring large datasets by categories without first preparing a separate summary table.
Pivoting is an Enterprise feature, not part of AG Grid Community. An application that uses it needs the appropriate AG Grid Enterprise package and a valid Enterprise licence. In modular installations, the required modules must also be registered; the module names and setup details can vary with AG Grid version and framework, so follow the documentation for the version installed in the project.
Pivoting does not normally rewrite the application’s source records. It changes how the grid presents and aggregates them. That distinction matters: a pivot view is an interactive summary, not a replacement for the original data or a guarantee that the underlying records have been permanently transformed.
Rows, Pivot Columns, and Values
A pivot view is easiest to understand as three roles assigned to columns:
- Row groups: Categories displayed down the left side, such as country, department, or product.
- Pivot columns: Categories whose distinct values become headings across the top, such as year, quarter, or channel.
- Value columns: Measures summarized in the resulting cells, such as sales, units, or hours.
For example, imagine source records with Country, Year, and Sales fields. Set Country as a row group, Year as a pivot column, and Sales as a value using a sum aggregation. The resulting view can show countries down the side, separate columns for the years found in the data, and each country’s total sales for each year.
These roles are independent. A field can be a row group without pivoting, and a pivot column does not itself provide a number to summarize. A useful pivot usually has at least one row group, at least one pivot field, and a value field with a suitable aggregation.
Configure a Basic Pivot Table
In a JavaScript grid configuration, pivoting is controlled by grid options and column definitions. The following illustrates the central settings; adapt the surrounding grid setup to the framework and AG Grid version in use.
const gridOptions = {
columnDefs: [
{ field: 'country', rowGroup: true, hide: true },
{ field: 'year', pivot: true, hide: true },
{ field: 'sales', aggFunc: 'sum' }
],
pivotMode: true
};
Here, Country supplies the row groups, Year supplies the generated pivot columns, and Sales is summarized with the built-in sum aggregation. Setting pivotMode: true enables pivot mode for the grid. The rowGroup and pivot properties assign column roles, while aggFunc defines how values are combined.
The example hides the source columns because their values are being used to construct the grouped view. Hiding is a presentation choice, not a requirement: a developer may keep source columns visible or allow users to change their roles through the grid’s column controls. If users should configure the view themselves, make sure the relevant columns and the appropriate column-tool-panel functionality are available.
For a working application, also provide the grid’s row data and normal setup, such as the grid element and any framework-specific component wiring. Configure the Enterprise licence and required modules according to the installed release. The short example is not a complete application entry point.
Build a Sales Summary Step by Step
Suppose a report contains these records: Canada, 2024, 120; Canada, 2025, 150; Japan, 2024, 90; and Japan, 2025, 110. With Country as the row group, Year as the pivot, and Sales summed, the meaningful cells are Canada–2024: 120, Canada–2025: 150, Japan–2024: 90, and Japan–2025: 110. The view presents the years as columns rather than repeating the year on every source row.
A practical configuration process is:
- Confirm that the application uses AG Grid Enterprise and has the correct licence and module setup.
- Check that the row data contains the fields needed for categories and measures.
- Choose a row group that makes the summary easy to scan, such as region or product.
- Choose a pivot field with a manageable number of distinct values, such as year or status.
- Set one or more measure columns and choose aggregations that match their meaning.
- Test the resulting view with representative data, including missing values and new category values.
The example uses year values because they tend to produce a compact set of headings. Pivoting on a field with hundreds or thousands of distinct values can create an extremely wide grid, making the result difficult to use even if the configuration is technically valid.
Use the Grid Interface to Explore Data
AG Grid can expose pivot controls through its column tool panel, depending on the application’s configuration. Users can then arrange columns into row-group, pivot, and value areas and switch pivot mode on or off. This lets an application provide an exploratory interface instead of fixing every analysis in code.
The exact controls visible depend on the version, theme, framework integration, and which tool-panel features the developer enables. A user may not see pivot controls simply because pivoting is available in the installed Enterprise package; the application still needs to expose the relevant interface or set the column definitions programmatically.
For a stable report, defining the pivot configuration in code can make the initial view predictable. For an analyst-facing data explorer, user-configurable controls may be more appropriate. Some applications combine both approaches: they start with a useful default configuration and allow users to adjust it.
Choose Aggregations and Prepare Data
The aggregation should reflect what the measure means. Sum is appropriate for additive quantities such as revenue or units sold. An average can be useful for values such as response time, but an average of averages may be misleading if the underlying groups have different sizes. Minimum and maximum answer different questions, while a count can summarize the number of contributing records or values depending on the configured aggregation and data.
Consider whether a measure is additive before using it across several dimensions. Adding transaction amounts is usually meaningful; adding percentages, ratios, or account balances across unrelated groups often is not. If the desired calculation needs weighted averages or other domain-specific logic, use an aggregation approach designed for that calculation rather than assuming a basic average will be correct.
Data quality affects the result. Ensure that numeric measures are represented as numbers rather than formatted text, and decide how blank or missing category values should appear. Also check whether labels that look identical contain differences such as trailing spaces or inconsistent capitalization, since these can create separate categories. If pivot values arrive dynamically, new distinct values may result in new generated columns.
Common Problems and How to Diagnose Them
- No pivot controls appear: Check that the application uses Enterprise, that the licence and required modules are set up, and that the column tool panel exposes the controls. Also confirm that pivot mode is enabled if the view is meant to start in pivot mode.
- The grid shows rows but no useful summary: Verify that a field is assigned as a value and that it has a suitable aggregation. A row group and pivot column alone do not specify what should be summarized in the cells.
- Values look wrong: Check the underlying data types and aggregation logic. Numeric-looking strings, missing values, duplicate records, or an unsuitable average can all produce unexpected summaries.
- There are too many generated columns: The pivot field may have too many distinct values. Choose a broader category, filter the dataset, or use a different report layout.
- Expected categories are absent: Check whether the records are present in the data supplied to the grid and whether filtering or other application logic excludes them. Pivot headings are based on the available data and configuration, not necessarily every value a business user expects.
- The grid is slow: Large datasets, many pivot values, grouping, and expensive custom aggregations can increase work. Review the data volume and generated column count, and consult the AG Grid documentation for the row model and server-side capabilities appropriate to the application.
AG Grid Pivoting Versus a Prebuilt Summary
A pivot view in AG Grid is useful when people need to explore categories interactively inside a web application. The application can define a default summary, and users may be able to change dimensions and measures if the interface allows it. This is different from preparing a fixed summary in a database query, backend service, spreadsheet, or reporting tool.
A pre-aggregated dataset can be preferable when the report must follow a fixed business definition, when calculations belong on the server, or when transmitting every source record to the browser is impractical. In those cases, the server can supply summarized rows, and the grid can display them without relying on client-side pivoting. The right choice depends on data size, security, calculation rules, and the level of interaction users need.
AG Grid pivoting is also not the same as an Excel PivotTable, even though both present grouped summaries. AG Grid is a web UI component configured by application code; an Excel PivotTable is a spreadsheet feature with its own workflow and data model. The concepts overlap, but instructions and capabilities are not interchangeable.
Generated Columns, Totals, and Application Design
Pivot headings are generated from values in the pivot field, so the grid’s visible columns can change as the data changes. Plan for this in the surrounding interface: broad datasets may require horizontal scrolling, and users may need filters or a constrained date range to keep the view legible. Test with realistic category counts rather than only a small sample.
AG Grid offers options for displaying pivot totals and configuring related behaviors, but the exact settings should be checked against the documentation for the installed version. Totals can help readers compare row or column summaries, but they should be interpreted carefully. A total of percentages, averages, or other non-additive measures may not have the meaning users assume.
When the grid is part of a reporting workflow, clarify which filters are applied, what each aggregation means, and whether the displayed numbers are computed from all records or a subset. Clear labels and a visible indication of the chosen dimensions make an interactive pivot more trustworthy and easier to reproduce.
Frequently Asked Questions
Is AG Grid pivoting free?
No. Pivoting is an AG Grid Enterprise feature. Community users need an Enterprise package and valid licence to use it, along with any required module setup for their installation.
How do I enable pivot mode in AG Grid?
Set pivotMode: true in the grid options to enable it programmatically. Assign column roles using properties such as rowGroup, pivot, and aggFunc. The column tool panel can also expose controls if the application enables them.
Why is my pivot table empty?
Check that pivot mode is enabled, at least one column is assigned as a value with an aggregation, and row data includes the fields used by the configuration. Also check licence, module registration, filters, and whether the grid’s UI has the necessary controls.
Can AG Grid pivot data on the server?
AG Grid supports different row models and server-side workflows, but the implementation and available pivot behavior depend on the row model, Enterprise setup, and version. Consult the documentation for the exact installed release before assuming client-side and server-side pivoting behave identically.
Can I use AG Grid pivoting in React or Angular?
Yes. AG Grid has framework integrations, including React and Angular. The pivot concepts are the same, but installation, module registration, and component setup follow the framework-specific instructions for the version being used.
Related
- How to Make a Custom Sorting List in Excel
- How to Strikethrough Numbers in Excel: Steps and Tips
- How to Make Serial Numbers in Excel: 4 Easy Methods
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Pivot Chart Histogram: What Works and What Doesn’tExcel does not provide a true Histogram chart as a PivotChart type. You can, however, group numeric values…
- Creating a Pie Chart in Excel: Steps, Labels, and TipsTo create a pie chart in Excel for Microsoft 365 on Windows, arrange category names beside their values,…
- Excel Line Chart: Plotting Total Values Over TimeTo make an Excel line chart that uses total values, put each period or category in one column…
- Excel Half-Moon Chart: Add Red, Yellow, and Green ZonesTo create a red, yellow, and green half-moon chart in Excel, make a doughnut chart from three equal…
- Edit a Gantt Chart in Excel: Dates, Tasks, and BarsYes. To edit a Gantt chart in Excel, change the task names, start dates, finish dates, or durations…
- Excel Pivot Tables With Multiple Data Sources: How-ToYes. In Excel for Microsoft 365 on Windows, you can build one PivotTable from multiple tables by adding…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.