Pivot Tables Component

Embed interactive pivot tables for data analysis and cross-tabulation using the rb-pivot-table web component.


Table of Contents

Live Examples

Click Configuration on any demo to switch to the Configuration view with a copy button.


Fundamentals

Basic Sum Pivot Table

The starting point for any pivot: one row dimension, one value field, one aggregator. This example groups revenue by region using rows, vals, aggregatorName, and rendererName — the four properties every pivot config needs.

Loading…

pivotTable {
  rows 'region'
  vals 'revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
}

Cross-Tabulation

Adding cols turns a flat list into a matrix. Here products form the rows, quarters form the columns, and the Count aggregator tallies orders per cell — the classic cross-tab found in every ERP and sales analytics tool.

Loading…

pivotTable {
  rows 'product'
  cols 'quarter'
  aggregatorName 'Count'
  rendererName 'Table'
}

Multi-Dimension

Multiple entries in rows and cols create nested hierarchies — region then country on the left, product line across the top. Executives use this three-way breakdown to drill from high-level totals into the specific country and product driving the numbers.

Loading…

pivotTable {
  rows 'region', 'country'
  cols 'productLine'
  vals 'revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
}

Average Aggregator

Switching from Sum to Average changes the analytical question entirely. "What is the typical order value per sales channel?" reveals that Enterprise orders are 10x the size of Marketplace orders — information hidden when you only look at totals.

Loading…

pivotTable {
  rows 'salesChannel'
  vals 'orderValue'
  aggregatorName 'Average'
  rendererName 'Table'
}

Filtering & Sorting

Value Filter

The valueFilter property removes specific dimension values before any calculation runs. Here Inactive and Pending records are excluded so the pivot shows only Active revenue — essential when source data contains mixed statuses and you need a clean view.

Loading…

pivotTable {
  rows 'category'
  vals 'revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
  valueFilter {
    status exclude: ['Inactive', 'Pending']
  }
}

Sorted by Value Descending

rowOrder 'value_z_to_a' ranks rows by their aggregated total (highest revenue region on top), while colOrder 'key_a_to_z' keeps years in chronological order. This combination — value-ranked rows, time-ordered columns — is the standard executive summary layout.

Loading…

pivotTable {
  rows 'region'
  cols 'year'
  vals 'revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
  rowOrder 'value_z_to_a'
  colOrder 'key_a_to_z'
}

Custom Sort Order

sorters overrides alphabetical ordering with a business-specific sequence. Here regions appear as West → Central → East → International, matching how the sales organization is structured rather than the dictionary.

Loading…

pivotTable {
  rows 'region'
  vals 'revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
  sorters region: ['West', 'Central', 'East', 'International']
}

Renderers

Heatmap

The Table Heatmap renderer colors every cell relative to the global maximum — the highest value across the entire table gets the darkest shade. Useful for spotting the single biggest number at a glance. In this CRM pipeline, Nora's Negotiation deals immediately stand out as the peak.

Loading…

pivotTable {
  rows 'dealStage'
  cols 'salesRep'
  vals 'dealValue'
  aggregatorName 'Sum'
  rendererName 'Table Heatmap'
}

Grouped Bar Chart

Grouped Bar Chart places one bar per column value side by side for each row. Here each deal stage shows three bars — one per sales rep — so you can instantly compare individual contributions within a stage. Nora dominates Negotiation, Priya leads Qualification, and Closed Won is Marco's strength.

Loading…

pivotTable {
  rows 'dealStage'
  cols 'salesRep'
  vals 'dealValue'
  aggregatorName 'Sum'
  rendererName 'Grouped Bar Chart'
}

Line Chart

Line Chart draws one line per sales rep across deal stages, making it easy to follow each person's pipeline trajectory. All three reps peak at Negotiation before dropping at Closed Won — the classic pipeline funnel shape. Where lines cross or diverge reveals exactly at which stage performance differs.

Loading…

pivotTable {
  rows 'dealStage'
  cols 'salesRep'
  vals 'dealValue'
  aggregatorName 'Sum'
  rendererName 'Line Chart'
}

Aggregators

Revenue per Unit (Ratio)

Sum over Sum divides the first val by the second — here revenue / quantity — producing a price-per-unit ratio. Widget B commands the highest unit price (around $800), while Gadget X is a volume play (around $155). This is the only aggregator that uses two value fields simultaneously.

Loading…

pivotTable {
  rows 'product'
  cols 'quarter'
  vals 'revenue', 'quantity'
  aggregatorName 'Sum over Sum'
  rendererName 'Table'
}

Percentage of Total

Sum as Fraction of Total converts raw numbers into percentages of the grand total. Each cell shows what share of overall revenue it represents — making it immediately clear that North America Software alone accounts for nearly a third of all revenue.

Loading…

pivotTable {
  rows 'region'
  cols 'productLine'
  vals 'revenue'
  aggregatorName 'Sum as Fraction of Total'
  rendererName 'Table'
}

Count Distinct

Count Unique Values counts how many distinct values appear, not how many rows exist. Here it answers "how many different products were ordered per region per quarter?" — a fundamentally different question than Count, which would just tally rows regardless of duplicates.

Loading…

pivotTable {
  rows 'region'
  cols 'quarter'
  vals 'product'
  aggregatorName 'Count Unique Values'
  rendererName 'Table'
}

Advanced

Derived Attributes (Year from Date)

derivedAttributes creates new dimensions from existing fields at render time. Here year and quarter are extracted from raw orderDate timestamps, so users can pivot by time period without the source data needing pre-computed year/quarter columns.

Loading…

pivotTable {
  rows 'region'
  cols 'year'
  vals 'revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
  derivedAttributes year: 'dateFormat(orderDate, "%y")', quarter: 'dateFormat(orderDate, "Q%q")'
}

Field Visibility Controls

Three levels control what users see and interact with. hiddenAttributes removes fields entirely (internal IDs, timestamps). hiddenFromAggregators keeps fields draggable as dimensions but prevents them from being summed or averaged (employee names, free-text notes). hiddenFromDragDrop locks a field in place so users cannot rearrange it.

Loading…

pivotTable {
  rows 'department'
  vals 'salary'
  aggregatorName 'Average'
  rendererName 'Table'
  hiddenAttributes 'employee_id', 'manager_id', 'created_at'
  hiddenFromAggregators 'employeeName', 'notes'
  hiddenFromDragDrop 'department'
}

Putting It All Together

Sales Overview — Region × Product × Quarter

What you're looking at: 64 rows of sales data — 4 Regions × 4 Products × 4 Quarters. The pivot table transforms this into an instant analysis grid. No SQL, no formulas.

Loading…

pivotTable {
  rows 'Region', 'Product'
  cols 'Quarter'
  vals 'Revenue'
  aggregatorName 'Sum'
  rendererName 'Table'
  rowOrder 'key_a_to_z'
  colOrder 'key_a_to_z'
}

Source data (64 rows) that feeds the pivot table above.

RegionProductQuarterSalesRepQuantityRevenueCostProfit
NorthLaptopQ1Carol1315,60011,354.774,245.23
NorthLaptopQ2Carol89,6006,518.293,081.71
NorthLaptopQ3Bob1720,40014,888.355,511.65
NorthLaptopQ4Bob910,8007,908.942,891.06
NorthPhoneQ1Carol118,8005,540.383,259.62
NorthPhoneQ2Carol1814,4009,958.944,441.06
NorthPhoneQ3Alice1411,2008,126.733,073.27
NorthPhoneQ4Alice1612,8007,740.555,059.45
NorthTabletQ1Bob63,0001,883.561,116.44
NorthTabletQ2David157,5004,530.512,969.49
NorthTabletQ3Alice2110,5007,068.193,431.81
NorthTabletQ4David115,5003,671.161,828.84
NorthMonitorQ1Alice62,1001,435.33664.67
NorthMonitorQ2Carol93,1502,195.09954.91
NorthMonitorQ3Alice113,8502,736.551,113.45
NorthMonitorQ4David155,2503,310.81,939.2
SouthLaptopQ1Bob1012,0007,334.454,665.55
SouthLaptopQ2Carol1821,60015,205.616,394.39
SouthLaptopQ3David67,2005,339.231,860.77
SouthLaptopQ4Bob2327,60017,128.4210,471.58
SouthPhoneQ1Alice54,0002,616.271,383.73
SouthPhoneQ2Bob1713,6009,995.13,604.9
SouthPhoneQ3Alice1915,20011,251.53,948.5
SouthPhoneQ4Bob1915,2009,529.545,670.46
SouthTabletQ1Carol2110,5006,489.934,010.07
SouthTabletQ2David168,0005,899.342,100.66
SouthTabletQ3Bob168,0005,204.352,795.65
SouthTabletQ4Carol115,5003,901.771,598.23
SouthMonitorQ1Bob134,5503,305.431,244.57
SouthMonitorQ2Carol248,4006,161.652,238.35
SouthMonitorQ3Bob155,2503,383.041,866.96
SouthMonitorQ4Alice186,3004,076.072,223.93
EastLaptopQ1David2327,60016,947.6810,652.32
EastLaptopQ2Bob2125,20015,611.329,588.68
EastLaptopQ3David89,6006,781.582,818.42
EastLaptopQ4Carol910,8007,148.843,651.16
EastPhoneQ1Alice1814,4009,365.615,034.39
EastPhoneQ2Alice1713,6009,969.233,630.77
EastPhoneQ3Bob2016,00010,543.075,456.93
EastPhoneQ4Alice2217,60011,536.046,063.96
EastTabletQ1Alice199,5006,605.252,894.75
EastTabletQ2David2311,5007,260.514,239.49
EastTabletQ3Carol147,0004,393.222,606.78
EastTabletQ4Alice199,5006,709.432,790.57
EastMonitorQ1Bob103,5002,276.711,223.29
EastMonitorQ2Alice93,1502,359.44790.56
EastMonitorQ3Carol248,4005,246.473,153.53
EastMonitorQ4Alice165,6003,605.71,994.3
WestLaptopQ1Bob1315,60010,338.955,261.05
WestLaptopQ2Carol1214,4009,366.025,033.98
WestLaptopQ3David1113,2008,900.624,299.38
WestLaptopQ4Carol1518,00012,391.15,608.9
WestPhoneQ1Alice118,8005,674.393,125.61
WestPhoneQ2Bob1814,4009,117.135,282.87
WestPhoneQ3Alice1814,4009,318.725,081.28
WestPhoneQ4Alice118,8005,335.993,464.01
WestTabletQ1Carol94,5003,025.041,474.96
WestTabletQ2Bob199,5007,000.492,499.51
WestTabletQ3David136,5004,050.292,449.71
WestTabletQ4David157,5005,445.422,054.58
WestMonitorQ1David144,9003,047.751,852.25
WestMonitorQ2Carol217,3504,639.772,710.23
WestMonitorQ3Bob155,2503,925.291,324.71
WestMonitorQ4Bob227,7005,593.892,106.11

Quick Actions (Try These Now)

1. Change the Metric Current: Sum of Revenue


Try: Click the Revenue ▼ dropdown (top area) → Select Profit


→ Now see profit margins. High revenue but low profit? You'll spot it instantly.

2. Rearrange Dimensions Try: Drag Quarter from columns → Drop into rows below Region


→ Now quarters are rows. "Which quarter was strongest?" — see row totals immediately.

3. Add a Dimension Try: Drag SalesRep from unused area → Drop into rows after Product


→ See Region → Product → SalesRep hierarchy. "Who sold most Laptops in North?" — answered.

4. Filter Data Try: Click the triangle next to Region → Uncheck North and West


→ Table now shows ONLY South and East. Focus on what matters.

5. Change Aggregation Try: Click Sum ▼ dropdown (top left) → Select Average


→ See average per transaction, not totals. "Are Q4 prices higher or just more volume?"

6. Visualize as Chart Try: Click Table ▼ dropdown → Select Grouped Column Chart


→ Same data, visual format. Trends jump out. Try "Stacked Bar" or "Line Chart" too.

Real Business Questions This Answers

  • "Which product is our cash cow?" — Put Product in rows, look at Totals column. Laptop has the highest revenue.
  • "Is East region underperforming?" — Compare region totals in the current view. Spot gaps instantly.
  • "Who gets the sales bonus?" — Drag SalesRep to rows, sort by totals. Highest revenue wins.
  • "Are we profitable or just busy?" — Switch from Revenue to Profit. High revenue + low margins? Now you see it.

The Point: Why This Matters

Without pivot table:

-- Question 1: Revenue by region
SELECT Region, SUM(Revenue)
FROM sales GROUP BY Region;
 
-- Question 2: Revenue by product
SELECT Product, SUM(Revenue)
FROM sales GROUP BY Product;
 
-- 20 more queries for different angles...

With pivot table:

Drag Region to rows → Question 1 answered
Drag Product instead → Question 2 answered
3 seconds total, no coding
1000 ways to slice the same data

Bottom line: Pivot tables = SQL GROUP BY + Excel formulas + visualization — combined. Drag and drop. Instant answers. Questions answered faster = better decisions.


How To Configure & Embed

First, configure your web components in ReportBurster — set up a report, define your data source, and customize the visualization under the Pivot Table tab.

Then drop the <rb-pivot-table> tag into any HTML page or framework component. Point it at your ReportBurster server and the web component handles data fetching, pivot calculation, and interactive rendering automatically.

<rb-pivot-table
  report-code="sales-analysis"
  api-base-url="http://localhost:9090/api/jobman/reporting">
</rb-pivot-table>

Tip: You can embed data directly in the config with data([...]) for small datasets that don't need a backend source. List syntax rows(['a', 'b']) also works alongside the comma form rows 'a', 'b'.

Attributes

AttributeRequiredDescription
report-codeYesReport folder name configured in ReportBurster
api-base-urlYesBase URL for API calls
component-idNoFor multi-component reports (see Dashboards)