SmartQueryTools

Add Cumulative Sum to CSV Files Online

Add a running total column to CSV files for any numeric column. Optionally order by a date or sequence column and restart totals per group — no upload required.

How to add Cumulative Sum to CSV files

  1. Drop your file onto the upload area. It is loaded into the in-browser engine and the first 200 rows are shown.
  2. Choose the value column to sum. Only numeric columns are listed, and the first one is preselected.
  3. Choose an Order by column, usually a date or sequence number. Leave it at (none) to add up rows in file order, top to bottom.
  4. Optionally choose a Partition by column so the running total restarts for each group. Rename the output column from cumulative_sum if you like, then click Add Cumulative Sum.
  5. Check the preview and download the file in the same format you uploaded.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

A facilities team logs daily solar generation in kWh for two roof arrays. They want month-to-date output for each array, so the running total must restart per site.

Input (CSV)

reading_date,site,kwh
2026-06-01,Roof A,18.5
2026-06-01,Roof B,11
2026-06-02,Roof A,21
2026-06-02,Roof B,9.5
2026-06-03,Roof A,16.5
2026-06-03,Roof B,12.5

Settings

  • Value column: kwh
  • Order by: reading_date
  • Partition by: site
  • Output column name: cumulative_sum

Result

reading_datesitekwhcumulative_sum
2026-06-01Roof A18.518.5
2026-06-01Roof B1111
2026-06-02Roof A2139.5
2026-06-02Roof B9.520.5
2026-06-03Roof A16.556
2026-06-03Roof B12.533

Each site gets its own running total in date order: Roof A goes 18.5, 39.5, 56 and Roof B goes 11, 20.5, 33. The rows stay in their original order. With Order by and Partition by both left at (none), the total would run down the file instead: 18.5, 29.5, 50.5, 60, 76.5 and 89.

Working with CSV files

The Order by column only works as intended if it loaded as a real date or number. ISO dates such as 2026-06-01 are detected as dates. If the column stays text, ordering is alphabetical: "10/06/2026" sorts before "2/06/2026", and the running total jumps about. Check the column type in the preview. If it shows VARCHAR, fix it with Parse Dates first. Codes such as invoice numbers order as text too, so INV-10 comes before INV-9.

Blank value fields load as NULL and are skipped. The running total carries forward unchanged on those rows, and it stays blank until the first non-empty value appears. The total accumulates in floating point, so a column of values like 0.1 can give 0.30000000000000004 after three rows. The downloaded CSV shows that full value, so round the result before sharing. The new column is added as the last field on each line.

Frequently Asked Questions

Why does my CSV running total jump around instead of rising steadily?

Usually the Order by column was loaded as text, so rows are ordered alphabetically rather than by date. Parse the dates first with Parse Dates, or order by a numeric sequence column.

What happens to empty cells in the CSV value column?

They are treated as NULL and skipped. The running total stays the same on those rows instead of resetting or dropping to zero.

What does (none) in Order by do?

It adds up rows in file order, top to bottom. With a Partition by column, each group has its own running total, still in file order. Pick a date or sequence column when the file is not already sorted.

How does the total restart for each group?

Choose a Partition by column. The total starts again at the first row of each group value, in Order by order or in file order when Order by is (none). Rows are not regrouped, so they keep their original order.

How are rows with the same Order by value handled?

They are added in file order, one row at a time. The result is the same every time you run it.

Related Tools

Add Percent of Total to CSV Files Online

Add a percentage-of-total column to CSV files directly in your browser. Show each row's share of the grand total, or the share within each group — no upload required.

Add Moving Average to CSV Files Online

Add a moving average, rolling sum, rolling min, or rolling max column to CSV files directly in your browser. Choose window size, order-by column, and optional partitioning — no upload required.

Add Lag / Lead Column to CSV Files Online

Add a LAG or LEAD column to CSV files to shift any column forward or backward by N rows. See previous day's sales, next value in a sequence, or any time-shifted comparison — runs entirely in your browser.

Add Cumulative Sum to Excel Files Online

Add a running total column to Excel files for any numeric column. Optionally order by a date or sequence column and restart totals per group — no upload required.

Add Cumulative Sum to Parquet Files Online

Add a running total column to Parquet files for any numeric column. Optionally order by a date or sequence column and restart totals per group — no upload required.

Add Cumulative Sum to JSON Files Online

Add a running total column to JSON files for any numeric column. Optionally order by a date or sequence column and restart totals per group — no upload required.

CSV Viewer Online

View and inspect CSV files directly in your browser. Browse rows, check column names and data types — no upload required, your data stays on your device.

Convert CSV to Parquet Online

Convert CSV files to Parquet format directly in your browser. No upload required — your data never leaves your device.