# PivotGrid

Source: https://lumeo.nativ.sh/components/pivot-grid

# PivotGrid

A cross-tab grid that pivots flat data into a row hierarchy × columns × aggregated measures — like an Excel PivotTable.

## When to Use

-   Summarize transactional rows by one or more dimensions — e.g. sales by region and year.
-   Compare a measure (sum, average, count, min, max) across categories at a glance.
-   Give analysts a collapsible, subtotalled cross-tab without wiring up a full BI tool.
-   Reach for [DataGrid](/components/data-grid) instead when users need to see, sort and edit the raw rows themselves.

Preview Code

Sales by region × year

Region

FY 2023

FY 2024

Grand Total

Revenue

Revenue

Revenue

APAC

$64,000

$120,000

$184,000

Americas

$260,000

$229,000

$489,000

EMEA

$160,000

$164,000

$324,000

Grand Total

$484,000

$513,000

$997,000

Copy Code

Preview Code

Multiple measures (sum + count)

Region

FY 2023

FY 2024

Grand Total

Revenue

Deals

Revenue

Deals

Revenue

Deals

APAC

$64,000

1

$120,000

2

$184,000

3

Americas

$260,000

3

$229,000

3

$489,000

6

EMEA

$160,000

2

$164,000

2

$324,000

4

Grand Total

$484,000

6

$513,000

7

$997,000

13

Copy Code

Preview Code

Collapsible nested row groups

Click a region row to collapse its countries; the subtotal stays visible.

Region

Country

FY 2023

FY 2024

Grand Total

Revenue

Revenue

Revenue

APAC

$64,000

$120,000

$184,000

India

$0

$41,000

$41,000

Japan

$64,000

$79,000

$143,000

APAC Total

$64,000

$120,000

$184,000

Americas

$260,000

$229,000

$489,000

Brazil

$0

$33,000

$33,000

Canada

$42,000

$51,000

$93,000

USA

$218,000

$145,000

$363,000

Americas Total

$260,000

$229,000

$489,000

EMEA

$160,000

$164,000

$324,000

Germany

$88,000

$96,000

$184,000

UK

$72,000

$68,000

$140,000

EMEA Total

$160,000

$164,000

$324,000

Grand Total

$484,000

$513,000

$997,000

Copy Code

Preview Code

Multi-level column hierarchy (Year > Quarter)

Two column-field levels nest into a tree of headers, with the measure-name row at the bottom.

Region

Country

FY 2023

FY 2024

Grand Total

Q1

Q2

Q3

Q4

Q1

Q2

Q3

Q4

Revenue

Revenue

Revenue

Revenue

Revenue

Revenue

Revenue

Revenue

Revenue

APAC

$0

$0

$0

$64,000

$41,000

$79,000

$0

$0

$184,000

India

$0

$0

$0

$0

$41,000

$0

$0

$0

$41,000

Japan

$0

$0

$0

$64,000

$0

$79,000

$0

$0

$143,000

APAC Total

$0

$0

$0

$64,000

$41,000

$79,000

$0

$0

$184,000

Americas

$120,000

$42,000

$98,000

$0

$145,000

$51,000

$0

$33,000

$489,000

Brazil

$0

$0

$0

$0

$0

$0

$0

$33,000

$33,000

Canada

$0

$42,000

$0

$0

$0

$51,000

$0

$0

$93,000

USA

$120,000

$0

$98,000

$0

$145,000

$0

$0

$0

$363,000

Americas Total

$120,000

$42,000

$98,000

$0

$145,000

$51,000

$0

$33,000

$489,000

EMEA

$88,000

$72,000

$0

$0

$96,000

$0

$68,000

$0

$324,000

Germany

$88,000

$0

$0

$0

$96,000

$0

$0

$0

$184,000

UK

$0

$72,000

$0

$0

$0

$0

$68,000

$0

$140,000

EMEA Total

$88,000

$72,000

$0

$0

$96,000

$0

$68,000

$0

$324,000

Grand Total

$208,000

$114,000

$98,000

$64,000

$282,000

$130,000

$68,000

$33,000

$997,000

Copy Code

## API Reference

### PivotGrid<TItem>

Property

Type

Default

Description

Items

IEnumerable<TItem>?

null

The flat source rows to pivot.

RowFields

IReadOnlyList<PivotField<TItem>>

\[\]

Fields forming the (nested) row hierarchy, outermost first.

ColumnFields

IReadOnlyList<PivotField<TItem>>

\[\]

Fields forming the (nested) column hierarchy, outermost first. The header renders one row per level plus a final row for the measure names. Column subtotals are not produced — only row subtotals; the trailing grand-total column aggregates across all columns.

Measures

IReadOnlyList<PivotMeasure<TItem>>

\[\]

The value fields and their aggregation (Sum / Average / Count / Min / Max).

ShowRowGrandTotal

bool

true

Adds a trailing grand-total column aggregating across all column groups.

ShowColumnGrandTotal

bool

true

Adds a bottom grand-total row aggregating across all rows.

ShowSubtotals

bool

true

Renders a subtotal row under each non-leaf row group.

Collapsible

bool

true

Lets users collapse/expand a row group; collapsed groups show only their subtotal.

Compact

bool

false

Tighter cell padding.

GrandTotalLabel

string

"Grand Total"

Label used for the grand-total row and column.

EmptyContent

RenderFragment?

null

Shown when `Items` is empty.

OnCellClick

EventCallback<PivotCellClickArgs>

—

Invoked when a data cell is clicked; carries the row keys, column keys, measure header and the underlying rows for drill-down.

### PivotField<TItem>

Member

Type

Description

Header

string

Header label for this field level.

Selector

Func<TItem, object?>

Extracts the grouping value from a source row.

Format

Func<object?, string>?

Optional formatter for the displayed group label.

SortComparer

IComparer<object?>?

Optional custom ordering of the distinct values (natural order otherwise).

### PivotMeasure<TItem>

Member

Type

Description

Header

string

Header label for the measure.

Value

Func<TItem, decimal>

Extracts the numeric value to aggregate.

Aggregate

PivotAggregate

Sum (default), Average, Count, Min or Max.

Format

Func<decimal, string>?

Optional formatter for the aggregated number.

## Related Components

-   [DataGrid](/components/data-grid) — Enterprise grid with grouping, sorting, inline edit and export over raw rows.
-   [DataTable](/components/data-table) — Lightweight sortable/paginated table for flat data.
-   [Table](/components/table) — The styled HTML table primitive PivotGrid is built on.
-   [Chart](/components/chart) — Visualise the same aggregates as bars, lines or a heatmap.
