SmartQueryTools

Get Top N Rows from Excel Files Online

Extract the top N rows per group from Excel files directly in your browser. Get the top 5 products per category, highest scores per team, or any ranked subset — no upload required.

How to get Top N Rows from Excel files

  1. Drop your file onto the upload area. The first 200 rows are shown and the first numeric column is pre-selected as the ranking column.
  2. Choose Rank by column and a Direction: Highest first for the largest values, Lowest first for the smallest.
  3. Optionally choose a Group by column to get the top rows within each group. Leave it on (none) to rank the whole table.
  4. Set Top N (default 5). Tick Include rank position column if you want a rank_in_group column showing 1, 2, 3 within each group.
  5. Click Get Top N, check the row count and preview, then download the result in the same format.

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 race organiser has marathon finish times and wants the two fastest runners in each age group for the podium list.

Input (Excel)

Excel workbook, first sheet (Sheet1)

runnerage_groupfinish_minutes
Aroha NgataF40-49212.5
Megan DoyleF40-49198.25
Lena FischerF40-49205
Tom ReidM50-59187.75
Raj PatelM50-59201
Owen ClarkeM50-59179.5

Settings

  • Rank by column: finish_minutes
  • Direction: Lowest first
  • Group by: age_group
  • Top N: 2
  • Include rank position column: on

Result

runnerage_groupfinish_minutesrank_in_group
Megan DoyleF40-49198.251
Lena FischerF40-492052
Owen ClarkeM50-59179.51
Tom ReidM50-59187.752

Lower times are better, so Lowest first is used. Each age group is ranked on its own, and the slowest runner in each group drops out. The output is sorted by age_group and then by finish_minutes. The rank_in_group column is added at the end only because the rank option was ticked. With Group by left on (none), the result would be the two fastest runners overall: Owen Clarke and Tom Reid.

Working with Excel files

Only the first sheet is loaded, and each cell arrives as the text Excel displays. That matters for ranking. A sales column formatted as currency, such as "$1,200.00", becomes text and ranks alphabetically, so "$80.00" can outrank "$1,200.00". Set the column to General or Number format in Excel before exporting, or strip the symbols with Find & Replace and then Cast Columns.

Dates are easier. A cell with a date format, such as 3/2/26, loads as a real date, so "most recent N per customer" works directly. Check for dates stored as text instead. A pasted column like 1-Jun-26 stays text and ranks character by character, so run Parse Dates on it first. Merged cells are a common trap: only the top cell of a merged block keeps the group name, so the other rows land in a blank group. Unmerge and fill down in Excel first. The download is a new .xlsx with one sheet named Sheet1, sorted by group and rank. Cell formatting, column widths and any other sheets from the original workbook are not included.

Frequently Asked Questions

Why does my Excel ranking put small amounts above large ones?

The amounts are formatted as currency or with thousand separators, so they loaded as text. Change the cell format to General in Excel, or clean and cast the column first.

Is this like Excel's LARGE or TOP 10 filter?

Similar, but per group in one step. Excel's Top 10 filter works on the whole column. This tool returns the top N rows inside every group at once and keeps all columns.

What happens when two rows tie at the Nth position?

The tool uses ROW_NUMBER, so exactly N rows are returned per group and one of the tied rows is dropped. Which one is not guaranteed. If ties matter, use the Rank tool, which supports RANK and DENSE_RANK, and then filter.

Can I rank by a text or date column?

Yes. Rank by lists every column. Text ranks alphabetically and dates rank chronologically. The first numeric column is only the default.

Where are NULL values placed in the ranking?

After all non-NULL values, whichever direction you choose. They only appear in the result when a group has fewer than N rows with a value.

Related Tools