Skip to main content

CSV grouping guide

How to group CSV rows and calculate counts, sums, and averages

Turn detail rows into a summary by store, product, or region. Choose one to three group columns and up to ten summary calculations, then verify that every input row belongs to a group.

Published:

Updated:

Related tool: Group & summarize

Example: order count and revenue by state

Four order rows become two state summaries. Groups appear in the order their first row appeared in the input.

  • Group column: State
  • Calculation 1: Row count
  • Calculation 2: Sum of Amount USD

Order-level CSV

Amounts are plain numbers without dollar signs or thousands separators.

orders.csv
Order ID,State,Amount USD
A001,California,1280.00
A002,Texas,840.00
A003,California,2150.00
A004,Texas,990.00

Summary by state

California combines A001 and A003, giving 1280 + 2150 = 3430. Texas combines A002 and A004, giving 840 + 990 = 1830. The result has one row per state.

orders_grouped.csv
State,count_rows,Amount USD_sum
California,2,3430
Texas,2,1830

Check the summary totals

Add the two counts to get four and the two amounts to get 5260. To investigate missing amounts, add Non-empty count for Amount USD and subtract it from Row count. The difference is the number of orders with a missing amount.

  • Every input row is counted in one of the groups
  • There is one output row for each group
  • Adding the group totals gives the original detail total
  • Numeric blanks are ignored, while zero is included

Group and summarize a CSV

You can add average, minimum, and maximum for the same numeric column.

  1. Open Group and summarize and choose the CSV.
  2. Confirm encoding, delimiter, and column values.
  3. Select one to three group columns in priority order.
  4. Add between one and ten summary calculations.
  5. Run it, check the input row count, group count, and totals, then download.
Group & summarize

Common grouping mistakes

Make units and group labels consistent before calculating the summary.

  • Leaving commas or dollar signs in a numeric field
  • Creating separate groups with trailing spaces
  • Confusing row count with nonblank count
  • Using the result for accounting where rounding differences are unacceptable

When grouping is useful

Grouping replaces detail rows with a compact summary; it does not preserve every original column.

  • Good fit: totals by state, store, or product
  • Good fit: quick count, average, minimum, or maximum
  • Use Sort rows to reorder detail
  • Pivot columns and exact decimal accounting are unsupported