Multi-Level Sorting in Excel Explained | Jace Hollowridge

Learn how to sort by multiple columns.

It was 7:15 AM on a Tuesday and I was staring at a shipment report for fourteen regional offices: 4,200 rows, three sort columns, zero consistency in how the previous analyst had organized it. I needed Region sorted first, then Carrier, then Ship Date. One wrong click and the rows would scramble. The data had no helper column, no sort index, nothing to undo by. That's the moment multi-level sorting in Excel stopped being a menu option I clicked through and became something I actually thought about before touching.

Multi-level sorting lets you sort a data range by two or more columns at once (Region first, then Carrier within each region, then Ship Date within each carrier). This article covers both the Sort dialog box (the method most people need) and the SORTBY function (the modern, non-destructive alternative for Microsoft 365 users). Before either of those, though: one safety step you shouldn't skip.

Add a helper column. Number your rows 1 through whatever before you sort. If the result looks wrong, you can sort by that column to restore the original order. Ctrl+Z works too, but only if you haven't closed the file. Sorting is a permanent data movement, and I've seen people lose an afternoon of work because they assumed Undo would still be available after saving. It won't be.


Why Sort Order Matters More Than Most Guides Admit

The order you add your sort levels is the order Excel applies them, and new users get this backwards constantly. If you're sorting a dataset by Region, then Carrier, then Ship Date, Region is your primary sort. Excel groups by Region first, then sorts Carriers within each Region group, then sorts dates within each Carrier group. Reverse those levels and you get a completely different result. Sort priority matters a lot.

If you're just getting started with organizing data in Excel, the Excel for Beginners starter guide covers the foundational concepts that make sorting logic easier to follow.


Step 1: Open the Custom Sort Dialog Box and Build Your Sort Levels

With your helper column in place, you're ready to build the sort. Click anywhere inside your data range (not just one column, or Excel may sort that column in isolation and destroy your row relationships), then go to the Data tab on the ribbon and click Sort. The custom Sort dialog box opens.

How to Add a Level and Set Sort Order for Each Column

  1. In the Sort dialog box, confirm that My data has headers is checked in the top-right corner. If it's unchecked, your header row gets sorted into your data — an easy miss when you're moving fast.
  2. The first row in the dialog is your primary sort level. Use the Column dropdown to select your first sort column (for example, Region). Set Sort On to Cell Values and Order to A to Z.
  3. Click Add Level. A second row appears. Set this to your secondary column (for example, Carrier) with the same settings.
  4. Click Add Level again for a third level (for example, Ship Date). Set Order to Oldest to Newest.
  5. Click OK. Excel applies the sort: Region first, Carrier second, Ship Date third.

What the 3-Level Default Actually Means

Excel's Sort dialog defaults to showing three levels, but you can keep clicking Add Level beyond that — the UI scrolls. The real cap in Microsoft 365 is 64 levels, which is more than most people will ever need. If you're sorting a dataset that genuinely requires more than 64 criteria, that's a signal to move the logic into Power Query, where sort steps are explicit, documented, and repeatable.

My own rule: if I've manually sorted the same dataset three times, I automate it on the third instead.

For Mac users, the dialog behaves slightly differently. Sorting and filtering data in Excel on Mac covers those differences specifically.


Step 2: Use SORTBY to Sort by Multiple Columns with a Dynamic Formula

The dialog box method works great for one-time sorts. But if your data refreshes regularly (from a Power Query import or a connected source, for example), every refresh can silently overwrite your sort order. That's where SORTBY earns its place.

How SORTBY Differs from the Dialog Box

SORTBY is a dynamic array function available in Microsoft 365. It doesn't move your source data — it outputs a sorted result to a new range. The syntax for sorting by multiple columns looks like this:

=SORTBY(A2:D100, A2:A100, 1, B2:B100, 1, C2:C100, 1)

That formula sorts the range A2:D100 by column A ascending, then column B ascending, then column C ascending. Each sort column is followed by its direction: 1 for ascending, -1 for descending. Add more column/direction pairs to sort by as many columns as you need.

The SORT function is SORTBY's simpler sibling — it sorts by a single column index position rather than an array reference, which makes it useful for quick single-column dynamic sorts. SORTBY is the right tool for multi-column work. For the edge cases that trip people up most, common sorting errors and fixes goes deeper on dynamic sorting approaches.


Common Mistakes in Multi-Level Sorting (and How to Avoid Them)

Three mistakes account for the majority of "my sort is wrong" posts I see. All of them are avoidable.

Selecting only one column before opening the Sort dialog. Excel will warn you sometimes, but not always. If you've selected column A and sort, Excel may sort that column alone and disconnect it from the rest of your data. Always click a single cell inside your data range (not an entire column) before opening the dialog.

Watch out for numbers stored as text. A column containing 1, 2, 10, 20 will sort as 1, 10, 2, 20 if those values are text strings. The cell might look like a number — it isn't. Check for the green triangle in the cell corner, or use =ISNUMBER(A2) to confirm. This is the most common reason a multi-level sort produces unexpected results on imported data.

Merged cells anywhere in the sort range. Merged cells break sorting, break filtering, and will break your multi-level sort without a useful error message. Unmerge before you sort, no exceptions.


Frequently Asked Questions

How do you add multiple sort levels in Excel?

Open the Sort dialog box from the Data tab on the ribbon, configure your first sort level using the Column and Order dropdowns, then click Add Level to add each additional sort column. Excel applies the levels in the order they appear (top to bottom), so the first level is your primary sort.

What is the maximum number of sort levels in Excel?

In Microsoft 365 and modern Excel versions, you can add up to 64 sort levels in the custom Sort dialog box. The dialog displays a few levels at a time and scrolls as you add more — the 3-level appearance is a display default, not a hard cap.

How do you undo a sort in Excel?

Press Ctrl+Z immediately after sorting to undo, but this only works before you save and close the file. The safest approach is to add a helper column with sequential row numbers before sorting, so you can always re-sort by that column to restore the original order.

How is SORTBY different from the Excel Sort dialog box?

The Sort dialog box moves your actual data — it's a one-time, permanent operation. SORTBY is a dynamic array formula that outputs a sorted result to a separate range, leaving the source data untouched and auto-updating whenever the source changes. It's the better choice when your data refreshes regularly.