Google Sheets SORTN function
Sorts a range and returns only the first n rows: a top N. It is a Sheets-only function. It has the same name in Spanish Sheets.
Syntax
English Sheets
=SORTN(range, [n], [display_ties_mode], [sort_column1, is_ascending1])
Spanish Sheets (Mexico locale)
=SORTN(intervalo, [n], [modo_mostrar_equivalentes], [columna_ordenación1, es_ascendente1])
Spanish Sheets (Spain, Latin America)
=SORTN(intervalo; [n]; [modo_mostrar_equivalentes]; [columna_ordenación1; es_ascendente1])
| Argument | What it is |
|---|---|
| range | The data to sort. |
| noptional | How many rows to return; 1 by default. |
| display_ties_modeoptional | 0: exactly n rows. |
| sort_column1, is_ascending1optional | Which column to sort by and in which direction. |
Example
SORTN(range, n, 0, column, is_ascending) sorts and keeps the first n rows: a top N that updates itself. It is a Sheets-only function; the 0 says how to treat ties (no repeats).
=SORTN(A2:B9,3,0,2,FALSE)
Common mistake
Without a sort column it sorts by the first column ascending. For a top N use FALSE for is_ascending.
About Ads
This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.
Ads help us keep WebHerramientas free for everyone
Practice SORTN
Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons
Top 3 with SORTN
SORTN(range, n, 0, column, is_ascending) sorts and keeps the first n rows: a top N that updates itself. It is a Sheets-only function; the 0 says how to treat ties (no repeats).
In D2, show the top 3 salespeople with their sales, highest first.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Salesperson | Sales | Top 3 | |||
| 2 | Carmen | 48200 | ||||
| 3 | Jorge | 35900 | ||||
| 4 | Lucía | 61750 | ||||
| 5 | Andrés | 29400 | ||||
| 6 | Paola | 52300 | ||||
| 7 | Ricardo | 44100 | ||||
| 8 | Elena | 38650 | ||||
| 9 | Mateo | 57900 | ||||
| 10 |
The dotted outline shows how far the result should spill.
Frequently asked questions
- What is SORTN called in Spanish?
- It has the same name: SORTN. Functions that started in Google Sheets keep their English name even in a Spanish spreadsheet. What changes is the separator: Spain and much of Latin America separate arguments with semicolons.
- Why does SORTN use semicolons in some spreadsheets?
- It depends on each spreadsheet's locale, under File > Settings. Where the comma is the decimal mark (Spain, much of South America), arguments are separated by semicolons. Mexico and United States locales use commas.
- What is the most common SORTN mistake?
- Without a sort column it sorts by the first column ascending. For a top N use FALSE for is_ascending.