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])
| Argument | What it is |
|---|---|
| array | What is shown sorted. |
| by_array1 | The column that decides the order. |
| sort_order1optional | 1 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.
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.
In D2, list only the names, from the highest seller to the lowest.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Salesperson | Sales | Ranking | ||
| 2 | Carmen | 48,200 | |||
| 3 | Jorge | 35,900 | |||
| 4 | Lucía | 61,750 | |||
| 5 | Andrés | 29,400 | |||
| 6 | Paola | 52,300 | |||
| 7 | Ricardo | 44,100 | |||
| 8 | Elena | 38,650 | |||
| 9 | Mateo | 57,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.