How do I use SORTBY in Excel?
Use SORTBY when you want to sort data by another column. Enter Target range, Sort key range, Sort order in that order, then add optional arguments when needed.
Sorts array by another array.
SORTBY(array, by_array1, [sort_order1], ...)array
RequiredSpecify a reference range. You can drag or click start/end cells.
by_array1
RequiredSpecify a reference range. You can drag or click start/end cells.
sort_order1
OptionalEnter a numeric value.
Use SORTBY to return the result with these settings (Target range: A2:D8 (columns A to D), Sort key range: D2:D8 (Sales in column D), Sort order: -1 (descending)). You can set ranges by dragging from the start cell to the end cell in the same argument field.
| # | AProduct ID | BCategory | CProduct Name | DSales |
|---|---|---|---|---|
| 2 | P001 | Food | Apple | 1200 |
| 3 | P002 | Food | Banana | 980 |
| 4 | P003 | Stationery | Notebook | 450 |
| 5 | P004 | Stationery | Pen | 300 |
| 6 | P005 | Food | Grapes | 1500 |
| 7 | P006 | Stationery | Ruler | 250 |
| 8 |
How to Use (Formula)
=SORTBY(A2:D8, D2:D8, -1)Result
P005, Food, Grapes, 1500 | P001, Food, Apple, 1200 | P002, Food, Banana, 980 | P003, Stationery, Notebook, 450 | P004, Stationery, Pen, 300 | P006, Stationery, Ruler, 250 | , , ,
Use SORTBY when you want to sort data by another column. Enter Target range, Sort key range, Sort order in that order, then add optional arguments when needed.
Use the "Start Function Practice" button to jump straight into SORTBY drills.
The main arguments are Target range, Sort key range, Sort order. Start with the required ones, then add optional arguments if needed.