Excel SORTBY function

Sorts a range by another column, which does not have to appear in the result. In Spanish Excel it is called ORDENARPOR.

Syntax

English Excel

=SORTBY(array, by_array1, [sort_order1])

Spanish Excel (Mexico)

=ORDENARPOR(matriz, por_matriz1, [orden1])

Spanish Excel (Spain, Latin America)

=ORDENARPOR(matriz; por_matriz1; [orden1])

ArgumentWhat it is
arrayWhat is shown sorted.
by_array1The column that decides the order.
sort_order1optional1 ascending, -1 descending.

Example

SORTBY(range, by_range, order) sorts a range by another column that does not have to appear in the result. That gives you a ranking of names without showing the figures.

=SORTBY(A2:A9,B2:B9,-1)

Common mistake

Excel 365 and 2021 only. It takes several keys: by region, then by sales.

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 SORTBY

Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons

SORTBY

SORTBY(range, by_range, order) sorts a range by another column that does not have to appear in the result. That gives you a ranking of names without showing the figures.

Example=SORTBY(A2:A9,B2:B9,-1)ORDENARPOR = SORTBY

In D2, list only the names, from the highest seller to the lowest.

D2
ABCDE
1SalespersonSalesRanking
2Carmen48,200
3Jorge35,900
4Lucía61,750
5Andrés29,400
6Paola52,300
7Ricardo44,100
8Elena38,650
9Mateo57,900
10

Tip: while typing, click a cell or drag across several to insert their reference.

Frequently asked questions

What is SORTBY called in Spanish?
In Spanish Excel it is ORDENARPOR. The formula =SORTBY(A2:A9,B2:B9,-1) is written =ORDENARPOR(A2:A9;B2:B9;-1) (or with commas in Mexico).
Why does SORTBY use semicolons in some Excel versions?
It depends on regional settings. Where the comma is the decimal mark (Spain, much of South America), Excel separates arguments with semicolons. English Excel and Mexican Spanish Excel use commas.
What is the most common SORTBY mistake?
Excel 365 and 2021 only. It takes several keys: by region, then by sales.