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])

ArgumentWhat it is
rangeThe data to sort.
noptionalHow many rows to return; 1 by default.
display_ties_modeoptional0: exactly n rows.
sort_column1, is_ascending1optionalWhich 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.

Advertising
Loading ad...

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).

Example=SORTN(A2:B9,3,0,2,FALSE)SORTN: same name in Spanish

In D2, show the top 3 salespeople with their sales, highest first.

D2
ABCDEF
1SalespersonSalesTop 3
2Carmen48200
3Jorge35900
4Lucía61750
5Andrés29400
6Paola52300
7Ricardo44100
8Elena38650
9Mateo57900
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.