Σ

CSV Group & Aggregate

Group rows and calculate sum, average, count, min, or max

CSV Group & Aggregate — what it does

Group rows by one column and summarise another with count, sum, average, minimum or maximum. It is the single most common spreadsheet task — the pivot most people build to answer sales by region or hours by project — reduced to picking two columns and an operation.

Worked example

Eight orders grouped by region with the average unit price per region: group column region, value column unit_price, operation Average.

Input — orders.csv

order_id,region,product,qty,unit_price,order_date
1001,East,Notebook,12,3.50,2026-01-04
1002,West,Stapler,3,8.99,2026-01-04
1003,East,Notebook,5,3.50,2026-01-05
1004,North,Pen box,20,2.10,2026-01-06
1005,West,Notebook,7,3.50,2026-01-06
1006,East,Stapler,1,8.99,2026-01-07
1007,North,Pen box,15,2.10,2026-01-08
1008,West,Desk lamp,2,24.00,2026-01-08

Output — grouped.csv

region,average
East,5.33
West,12.163333333333334
North,2.1

Averages are written with full floating-point precision (12.163333333333334); round them in a spreadsheet if the file is for people. Groups appear in order of first appearance and the second header is the operation name.

When this tool helps

  • Totalling revenue by region, month or sales rep from a flat transaction export.
  • Counting how many records fall into each category to see how a dataset is distributed.
  • Finding the maximum value per group, such as the largest order placed by each customer.

How to use it

  1. Choose the CSV file.
  2. Select the column to group by.
  3. Select the value column and the operation.
  4. Process and download the summary.

Accuracy, limits, and good practice

  • Group labels are matched exactly, so North and north become two separate groups — normalise the column first if it was typed by hand.
  • Non-numeric cells are skipped by sum and average, which can quietly change the denominator; check the column statistics first.
  • Count answers how many rows, not how many distinct values. For distinct counts, deduplicate on that column before grouping.

Frequently asked questions

Can I group by two columns?

Use the pivot table tool, which takes a row field and a column field, or merge the two into one key first.

Are blank group values included?

Yes, they form their own group, which is often a useful signal that some rows are missing a category.

Can I apply several operations at once?

Run the tool once per operation and combine the outputs, or use the column statistics tool for a fuller numeric profile.

What is shown for a group whose value cells are blank or text?

Sum, average, minimum and maximum all show 0 for such a group, and count still counts every row, so a 0 can mean no usable data rather than a true zero. Check the column statistics tool when in doubt.

Is the download named after my file?

No. It is always grouped.csv, with two columns: the group column under its original header and the operation name (count, sum, average, min or max) as the second header. There is no byte-order mark.

Related tools on this site

Everything above runs inside this page. CSV Group & Aggregate needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

CSV 分組彙總能做什麼

依某一欄分組,再對另一欄計算筆數、加總、平均、最小或最大值。這是最常見的試算表工作——多數人建樞紐分析表就是為了回答「各地區業績」或「各專案工時」——在這裡簡化成選兩個欄位加一個運算。

實際範例

八筆訂單依地區分組,算各地區的平均單價:分組欄 region、數值欄 unit_price、運算選平均。

來源:orders.csv

order_id,region,product,qty,unit_price,order_date
1001,East,Notebook,12,3.50,2026-01-04
1002,West,Stapler,3,8.99,2026-01-04
1003,East,Notebook,5,3.50,2026-01-05
1004,North,Pen box,20,2.10,2026-01-06
1005,West,Notebook,7,3.50,2026-01-06
1006,East,Stapler,1,8.99,2026-01-07
1007,North,Pen box,15,2.10,2026-01-08
1008,West,Desk lamp,2,24.00,2026-01-08

得到:grouped.csv

region,average
East,5.33
West,12.163333333333334
North,2.1

平均值以完整浮點精度寫下(12.163333333333334),若檔案是給人看的,請在試算表裡再四捨五入。分組依首次見到的順序排列,第二個欄名是運算名稱。

什麼時候用得上

  • 從交易明細匯出檔中,統計各地區、各月份或各業務的營收合計。
  • 計算每個分類各有多少筆資料,看清資料的分布狀況。
  • 找出每組的最大值,例如每位客戶最大的一筆訂單。

使用步驟

  1. 選擇 CSV 檔案。
  2. 選定分組欄位。
  3. 選定數值欄位與運算方式。
  4. 執行處理並下載彙總結果。

精確度、限制與實務建議

  • 分組標籤採完全相符比對,North 與 north 會變成兩組;若該欄為手動輸入,建議先統一格式。
  • 加總與平均會略過非數值儲存格,可能悄悄改變分母,建議先看一次欄位統計。
  • 「計數」算的是列數而非不重複值。需要不重複計數時,請先對該欄去重再分組。

常見問題

可以用兩個欄位分組嗎?

請改用樞紐分析表工具(可同時指定列欄位與欄欄位),或先把兩欄合併成單一鍵值。

分組值為空白的列會被計入嗎?

會,它們會自成一組,這通常也是個有用訊號,代表有些資料沒有分類。

可以一次算多種運算嗎?

請每種運算各跑一次再合併輸出,或改用欄位統計工具取得較完整的數值輪廓。

某個分組的數值儲存格全是空白或文字時會顯示什麼?

總和、平均、最小值與最大值都會顯示 0,計數則仍把每一列都算進去,所以 0 可能代表沒有可算的資料而非真的是零。不確定時先以欄位統計工具核對。

下載檔會依我的檔名命名嗎?

不會,一律叫 grouped.csv,只有兩欄:分組欄沿襲原欄名,第二欄的欄名是運算名稱(count、sum、average、min 或 max)。開頭沒有 BOM。

本站相關工具

以上步驟全部在這個頁面內完成,CSV 分組彙總 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。