Excel SORTBY

SORTBY returns a list in the order set by another column, without moving your original data.

A sales manager wants a leaderboard that shows only names but is ordered by revenue. Sorting the source would disturb a table others rely on. SORTBY produces a separate ranking that reorders itself when new figures are entered.

Practice it now

How to write it

=SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2], ...)
array
What to return.
by_array1
The column that decides the order.
sort_order1
1 is ascending and -1 is descending.
by_array2, sort_order2
Optional tie-breaker.

Watch it work

F2fx 
ABCDEFG
1RepRegionQ3 salesDeals
2RosaEast4800012
3SamWest610009
4TaraEast3900015
5UmarNorth7200011
6VeraWest5500014
7
1

Names are returned, ordered by sales from high to low.

Examples

Best seller first

=SORTBY(A2:A6,C2:C6,-1)Umar

Names are returned, ordered by sales from high to low.

Most deals first

=SORTBY(A2:A6,D2:D6,-1)Tara

Change the by-column and you have a different leaderboard.

By region, then highest sales

=SORTBY(A2:A6,B2:B6,1,C2:C6,-1)Rosa

East comes first alphabetically and Rosa outsold Tara.

Your turn

List the reps from lowest Q3 sales to highest. Type your formula in F2.

ABCDEF
1RepRegionQ3 salesDeals
2RosaEast4800012
3SamWest610009
4TaraEast3900015
5UmarNorth7200011
6VeraWest5500014
7

Common mistakes

The by-column has a different height.

Excel returns #VALUE!. All ranges must match in size.

Blocked spill area.

Clear the cells below the formula to fix #SPILL!.

Good to know

  • The by-column need not appear in the output, unlike with SORT.
  • Combine with TAKE to show only the top three.
  • SORTBY or SORT? SORT orders by a column number inside the returned range. SORTBY orders by any separate range.