SmartQueryTools

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.

How to add Moving Average 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. Pick a window function: Moving Average (the default), Rolling Sum, Rolling Min or Rolling Max. The output column name changes to match, for example moving_avg or rolling_sum.
  3. Choose the value column (numeric columns only) and the window size in rows. The default is 3, and the window is the current row plus the rows before it.
  4. Choose an Order by column, usually a date, and optionally a Partition by column so each group gets its own series. Click Add Rolling Column.
  5. Check the preview, then 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 café tracks cups of coffee sold each day. Daily figures jump around with the weather, so the owner wants a 3-day moving average to see the underlying trend.

Input (CSV)

sale_date,weekday,cups_sold
2026-05-04,Mon,120
2026-05-05,Tue,150
2026-05-06,Wed,90
2026-05-07,Thu,180
2026-05-08,Fri,210
2026-05-09,Sat,150

Settings

  • Window function: Moving Average
  • Value column: cups_sold
  • Window size: 3 rows
  • Order by: sale_date
  • Partition by: (none)
  • Output column name: moving_avg

Result

sale_dateweekdaycups_soldmoving_avg
2026-05-04Mon120120
2026-05-05Tue150135
2026-05-06Wed90120
2026-05-07Thu180140
2026-05-08Fri210160
2026-05-09Sat150180

From Wednesday on, each value averages that day and the two before it: Thursday is (150 + 90 + 180) / 3 = 140. Monday and Tuesday do not have two earlier rows, so they average what is available: 120 alone, then (120 + 150) / 2 = 135. They are not left empty. Wednesday's dip is smoothed to 120, and the upward trend from Thursday is easy to see.

Working with CSV files

The window counts rows, not days. Many CSV exports from sales or analytics systems leave out days with no activity. A 7-row window over such a file can then span nine or ten calendar days. If you need a true 7-day average, make sure the CSV has one row per day, with zeros for quiet days, before you run the tool. The Order by column must also load as a date or number. A text column orders character by character, and the windows are built from the wrong neighbours.

Empty value cells load as NULL and are skipped inside the window. The average is taken over the non-empty values only, so one missing day does not drag the figure towards zero. Averages are written to the downloaded CSV at full precision, such as 146.66666666666666. Add a Round Numbers step if people will read the file. The new column is appended as the last field of each line.

Frequently Asked Questions

My CSV skips days with no sales. Is the 7-row average still a 7-day average?

No. The window counts rows, so missing days stretch it over a longer period. Add rows for the missing days with a value of 0 first if you need a strict calendar window.

How are blank values in a CSV handled inside the window?

They are ignored. The average uses only the non-empty values in the window, and it is empty only if every value in the window is empty.

How are the first rows handled when the window is not full yet?

They use whatever rows are available. With a window of 7, row 1 averages 1 value, row 2 averages 2, and from row 7 on every value covers 7 rows. No row is left empty for this reason.

Is the window centred or trailing?

Trailing. It covers the current row and the rows before it, up to the window size. Centred windows and exponential moving averages are not offered. Use the SQL Query tool with a custom window frame for those.

What is the difference between the four window functions?

Moving Average gives the mean of the window, Rolling Sum the total, and Rolling Min and Rolling Max the smallest and largest values. All four use the same window size, order and partition settings.

Related Tools

Round Numbers in CSV Files Online

Round numeric columns in CSV files to any number of decimal places directly in your browser. Set precision per column with a simple slider — 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.

Truncate Dates in CSV Files Online

Truncate date and timestamp columns in CSV files to a chosen precision — year, quarter, month, week, day, hour, or minute — directly in your browser. Rounds timestamps down to the start of each period. No upload required.

Add Moving Average to Excel Files Online

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

Add Moving Average to Parquet Files Online

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

Add Moving Average to JSON Files Online

Add a moving average, rolling sum, rolling min, or rolling max column to JSON files directly in your browser. Choose window size, order-by column, and optional partitioning — 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.