SmartQueryTools

Find Arg Max / Min in CSV Files Online

Find the value of one column at the row where another column is maximum or minimum in CSV files — directly in your browser. Optionally group by a category to get per-group results. No upload required.

How to find Arg Max / Min in CSV files

  1. Drop your file onto the upload area. The first 200 rows are shown. The second column is preselected as the one to find the max of, and the first column as the one to return.
  2. Choose the operation: arg_max for the row with the highest value, or arg_min for the lowest.
  3. Pick the "Find max of this column" and "Return the value of this column" columns. A sentence under the settings describes the query in plain words.
  4. Optionally pick a Group by column for one result per group, and name the output column. Left blank, it is named like date_at_max_temp.
  5. Click Find Arg Max (or Find Arg Min), check the result table, and download it as CSV.

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 weather hobbyist logs daily readings from three stations and wants the date of the hottest day recorded at each one. One reading from Auckland failed and has no temperature.

Input (CSV)

station,reading_date,temp_c,rain_mm
WLG,2026-01-14,21.4,0
WLG,2026-01-15,24.9,2.2
AKL,2026-01-14,26.1,0.4
AKL,2026-01-15,,5.8
AKL,2026-01-16,25.3,0
CHC,2026-01-15,29.8,0

Settings

  • Operation: arg_max
  • Find max of this column: temp_c
  • Return the value of this column: reading_date
  • Group by: station
  • Output column name: left blank (auto-generated)

Result

stationreading_date_at_max_temp_c
AKL2026-01-14
CHC2026-01-15
WLG2026-01-15

For each station the tool finds the row with the highest temp_c and returns its reading_date. Auckland's failed reading has no temperature, so it is skipped and 26.1 on 14 January wins. The output has one row per station, sorted by station, and the column name is built from the chosen columns because none was typed.

Working with CSV files

The comparison uses the type the column loaded as, and in a CSV that is inferred. If temp_c loaded as numbers, 9.5 is lower than 10.2 as expected. If a single value like "n/a" made the column text, values are compared alphabetically and "9.5" beats "10.2" because 9 sorts after 1. Check the type shown next to each column name in the pickers before running. Negative numbers written with a leading minus load fine, but values in brackets, like (120), or with a trailing currency sign stay text.

Empty fields in the value column are skipped, so a missing reading never wins. Rows where the returned column is empty are also skipped, which means the result can come from the second-highest row if the top row has no value to return. Dates written as 2026-01-14 load as real dates and compare in time order. The result downloads as a short CSV with the group column and one result column.

Frequently Asked Questions

Why does arg_max pick the wrong row in my CSV?

The value column probably loaded as text, so values were compared alphabetically. Clean non-numeric entries or use Cast Column Types to make it numeric, then run again.

What if the top row has an empty cell in the column I want returned?

That row is skipped, and the tool returns the value from the highest remaining row that has both values. Fill the gap first if the top row must count.

What happens when two rows tie for the maximum?

One of them is returned, and which one is not guaranteed. If ties matter, use Top N per Group or the SQL workspace to see every tied row.

How are NULL values handled?

Rows where either the value column or the returned column is NULL are skipped. If every row in a group is skipped, that group's result is empty.

Can I return the maximum value itself?

Choose the same column in both pickers and arg_max returns the maximum, but the Aggregate tool is the simpler way to get max and min values.

Related Tools