Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Views Pivot Table

No security coverage Under active development

Part of the Views ecosystem · 282 projects

Views Pivot Table adds a Pivot table (crosstab) format to Views. Pick one field for the rows, one for the columns and one for the values: each cell shows the values found for that row and that column, optionally summed, with optional totals.

No JavaScript library, no extra database query, no custom code: the table is built from the results your view already returns, using the rendered output of its fields.

Example

A view listing volunteer shifts (volunteer, day, hours), with "Volunteer" as row field, "Day" as column field, "Hours" as value field, and sums and totals turned on:

           | Friday | Saturday | Sunday | Total
-----------+--------+----------+--------+------
Alice      |      4 |        6 |      - |    10
Bob        |      2 |        3 |      5 |    10
Total      |      6 |        9 |      5 |    20

Features

  • Any field of the view can be used for rows, columns or values, including fields from relationships, with their formatter and "Rewrite results" settings.
  • Rows and columns are grouped on their plain text, so the same label always lands in the same row or column, even when it is rendered with different markup.
  • Cells with several values list them all, with a configurable separator (HTML allowed). Empty cells show a configurable text.
  • Optionally remove duplicate values in each cell, or replace the values of a cell with their sum.
  • Optional total row, total column and grand total, with a configurable label. Totals are always computed from all the underlying values, even when duplicates are hidden.
  • Configurable number format (decimals, decimal separator, thousands separator), used both to read numeric values and to display sums, so 1 234,50 works as well as 1,234.50.
  • Rows and columns can be sorted independently (ascending or descending, natural sort), or keep the order of the view results.
  • Views grouping fields are supported: one pivot table is displayed per group, including nested groups.
  • Accessible markup: row and column headers are <th> elements with a scope.
  • Themeable: a Twig template that can be overridden per view and display, and CSS classes on the totals.
  • Config schema, translatable labels, and automated tests.

Post-installation

  1. Create or edit a view that displays fields.
  2. In the "Format" section, set the format to Pivot table (crosstab).
  3. Choose the row field, the column field and the value field.
  4. Optionally set the separator, the empty cell text, sorting, duplicate removal, sums, totals and number format.
  5. Save the view.

Fields that are not used for rows, columns, values or grouping are not displayed, so you can keep helper fields in the view.

Good to know

  • The table is built from the results of the current page. If the view has a pager, rows and totals only cover the items of that page: set the pager to "Display all items" to get the complete table.
  • Results without a row value or a column value are skipped.
  • Sums and totals ignore non-numeric values. If the value field displays a prefix or suffix (for example a currency sign), hide it in the field formatter settings so the values can be read as numbers.

Theming

The table is rendered with the views-view-pivot-table.html.twig template, which can be overridden like any other Views template, for example views-view-pivot-table--VIEW-ID.html.twig. The total row and column have the pivot-table-total-row, pivot-table-total-column and pivot-table-total-cell classes.

Additional requirements

Drupal 10.3 or later, or Drupal 11, and the core Views module. No other dependency.

Similar projects

  • Views Aggregator Plus groups table rows on one column and applies summary functions to the other columns. Rows stay rows: it does not turn the values of a field into columns, which is what a pivot table does. Both modules can be used on the same site.
  • Pivot Tables for Views and Views Crosstab provided a similar feature for Drupal 7 only.
  • Core Views aggregation ("Use aggregation") computes sums and counts in SQL, but displays them as a flat list or table, not as a crosstab.

Ask your assistant about Views Pivot Table

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Oct 2026
Latest release
2 hours ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0-alpha1 Pre-release 10–11 Oct 25, 2026