Pivot table builder — sum, count or average a CSV by group

Name a row field, an optional column field and a value field, and the builder groups your CSV rows and fills a cross-table with the sum, count, average, minimum, maximum or distinct count, with row and column totals.

Live demo · real result from this tool

Drop your file here

or paste with Ctrl+V · nothing is uploaded

Or paste CSV / TSV in the box below. Excel files (.xlsx) use their first sheet.

Order

Loading the tool…

Processed on your device — nothing is uploaded.

How to use the pivot table builder

  1. Press Choose a file to load a CSV, TSV or Excel file, or paste your data into CSV data. The first row must be the header.
  2. Type the Row field (for example Region), and optionally a Column field (for example Quarter).
  3. Type the Value field to summarise, such as Revenue, or leave it blank to count rows.
  4. Choose Summarise by: Sum, Count, Average, Minimum, Maximum or Count of distinct values.
  5. Set Show totals, the Order (A → Z or As they appear) and the Decimals, then use the table’s CSV button to save pivot-table.csv.

What it does and when to use it

A pivot table answers “how much per group?” questions from a long list of records: revenue per region and quarter, orders per product, hours per person per project, or how many students chose each option in each class. You do not need a spreadsheet program, and the source data is never changed.

With only a row field you get a simple summary list, one line per group. Adding a column field turns it into a grid, which you can paste into the heatmap generator to colour the busiest cells, or chart with the stacked bar chart. To count the values of a single column, the frequency counter adds percentages as well.

How it works

Every data row is placed in a group by its row-field value and, if given, its column-field value. Each group collects its values, then the chosen measure is calculated:

  • Sum, Average, Minimum, Maximum: from the cells that read as numbers.
  • Count: filled value cells, or all rows when no value field is given.
  • Count of distinct values: different values after trimming spaces.

Row and column totals, and the grand total, are calculated from the underlying rows in the same way, so they are always correct for averages and distinct counts. A combination that never occurs leaves an empty cell. A → Z sorts group names ignoring case and with numbers in natural order (Q2 before Q10). Everything is calculated in your browser.

Worked examples

The sample has 8 sales rows with Region, Quarter, Product and Revenue.

Sum of revenue by region and quarter (the default).

Region | Q1 | Q2 | Total
East | 400 | 1300 | 1700
North | 2000 | 1500 | 3500
South | 700 | 2050 | 2750
Total | 3100 | 4850 | 7950

Average per region. Clear the column field and choose Average: East 850, North 1166.67, South 916.67, and Total | 993.75.

Count of rows by region and product. Clear the value field, set the column field to Product and choose Count. The East row reads East | 1 | 1 | 2, and the grand total is 8.

Limits and tips

  • One row field and one column field are supported; for a third grouping, combine two columns into one first.
  • Group names are trimmed and matched ignoring case: “ North” and “north” both join “North”. Each group is labelled with the first spelling in the data. Other differences, such as “N.” for “North”, still form separate groups; the CSV cleaner can also drop blank rows and stray columns.

Frequently asked questions

Does my file need a header row?
Yes. The fields are chosen by column name (or column number), so the first row must hold the names. Matching ignores upper and lower case and extra spaces.
How is the total of an average worked out?
From all the underlying rows, not from the averages in the table. In the sample, the overall average is 7,950 ÷ 8 = 993.75, which differs from the average of the three regional averages. Spreadsheet pivot tables work the same way.
What is the difference between Count and Count of distinct values?
Count counts filled value cells (or rows, when the value field is blank). Count of distinct values counts how many different values appear, so three orders from two customers give a distinct count of 2.
What happens to text in a number column?
For sum, average, minimum and maximum, cells that are not numbers are left out and a notice says how many were ignored. Values such as $1,200 or 12% are read as numbers.
What does "(blank)" mean in the table?
Rows whose row or column field is empty are grouped under "(blank)", so they are still counted rather than silently dropped.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close