Maintenance Notification: We are upgrading our servers today so you may experience intermediate outages. Thank you for your patience.
Perform data analysis
MO-211

Sort data by using SORTBY()

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

Spill the reps sorted by sales, largest first. SORTBY takes what to return, then the column to sort by and its order: 1 for ascending, -1 for descending.

What the MO-211 task asks

A SORTBY task in our MO-211 practice exams asks for a list in the order of something else: “in L4, one formula must spill the therapist names I4:I8 ordered by Caseload, largest first”, or “spill the twelve titles ordered by Net, largest first”.

Two details decide the marks. “Largest first” is descending, -1; SORTBY's default is ascending. And the sort column does not have to be returned: sorting names by caseload returns only the names.

“One formula must spill” means our grader checks for a dynamic-array formula and the spilled values. A list sorted with the Sort button, or typed in order, scores nothing.

Worked examples

Type these into a blank sheet to follow along. Every result below is what Excel showed.

Reps (the video spills E2:G6)
ABC
1RepRegionSales
2AnaEast420
3BenWest610
4CaraEast380
5DevNorth515
6EliWest290
Names ordered by another column
=SORTBY(A2:A6, C2:C6, -1)
Returns Ben, Dev, Ana, Cara, Eli

Only the names spill, in the order of their sales, largest first.

The default order
=SORTBY(A2:A6, C2:C6)
Returns Eli, Cara, Ana, Dev, Ben

Without a sort order, SORTBY sorts ascending: smallest first.

Two sort keys
=SORTBY(A2:C6, B2:B6, 1, C2:C6, -1)
Returns Ana, Cara, Dev, Ben, Eli (with their regions and sales)

Region A to Z first, then within each region sales largest first: East has Ana's 420 before Cara's 380.

Whole rows, largest first
=SORTBY(A2:C6, C2:C6, -1)
Returns Ben West 610, Dev North 515, Ana East 420, Cara East 380, Eli West 290, spilling into E2:G6

All three columns, ordered by Sales. This is what the video below builds, in E2.

Watch it done in Excel

The last example above, recorded in real Excel on the same grid.

Exam traps

Ascending where the task says largest first

=SORTBY(A2:A6, C2:C6) puts Eli first. “Largest first” needs the -1.

A sort column of a different height

=SORTBY(A2:A6, C2:C5, -1) returns #VALUE!: the column you sort by must be as tall as what you return.

Including the header

=SORTBY(A1:A6, C1:C6, -1) sorts the header in with the data, and Rep comes out at the top only because the text Sales sorts above every number.

Sorting by hand

Data > Sort reorders the source and leaves no formula. A task that says “one formula must spill” checks for the formula.

FAQ

SORTBY or SORT?

SORT is on MO-210 and sorts by a column of what it returns. SORTBY, on MO-211, sorts by any column, returned or not, and takes several sort keys.

What does 0 do as a sort order?

Nothing useful: =SORTBY(A2:A6, C2:C6, 0) returns #VALUE!. The order is 1 or -1.

Does the spill update when the data changes?

Yes. Change Eli's sales to 700 and he moves to the top of the spill straight away.

New to this function?

This page covers what the exam asks. For the full how-to — every argument, more examples and a practice workbook — read our guide on dfwexcel.com.

The SORTBY function, explained — dfwexcel.com

Try it under exam conditions

Take a full, timed MO-211 practice exam, upload the workbook you built, and get a score out of 1000 with a per-task breakdown of where the points went. Your first one is free.

No credit card needed.