How to Sort By Two Columns in Excel

Learn multiple Excel methods to sort by two columns with step-by-step examples, business use cases, and advanced techniques.

excelformulaspreadsheettutorial
11 min read • Last updated: 7/2/2025

How to Sort By Two Columns in Excel

Why This Task Matters in Excel

In any data-driven role—finance, sales, operations, HR, research, or education—you constantly need to make sense of lists. Those lists rarely arrive in perfect order. A payroll export might need to appear alphabetically by department and then chronologically by hire date. A product catalog may need to show category first and price second so managers can quickly scan the most expensive items inside each category. When you can sort by two columns, you structure information in a way that reveals patterns, speeds decision-making, and reduces manual scanning.

Consider a sales report with thousands of rows: sales region, salesperson, and total revenue. Sorting solely by revenue hides underperformers in larger regions. Sorting first by region and then by revenue allows managers to compare reps fairly. In supply-chain, sorting purchase orders first by supplier and then by delivery date quickly spotlights late shipments per vendor. Education administrators often sort student scores first by subject and then score descending to see top performers in each subject at a glance.

Excel excels (pun intended) in this domain because it offers both point-and-click tools and formula-based, dynamic sorting. Whether your organization runs on Microsoft 365 with dynamic arrays, or you are stuck on an older on-premise version, Excel still offers at least one reliable way to reorder data. If you remain unaware of multi-column sorting, you may waste hours applying single sorts sequentially—only to find results silently broken when new data arrives. Worse, reporting mistakes risk poor business decisions, from inventory shortages to compliance violations.

Learning to sort by two columns connects directly to other core skills: filtering, PivotTables, VLOOKUP/XLOOKUP, and dashboards. Once your data is in a stable, logical order, downstream formulas perform faster, charts update accurately, and Power Query loading stays predictable. Mastering this technique is therefore a high-leverage investment in your overall Excel workflow.

Best Excel Approach

The best all-round method is the built-in Sort dialog because it works in every modern Excel version, respects formatted tables, and is instantly intuitive. For users on Microsoft 365 or Excel 2021+, the dynamic array function SORT (or SORTBY) is equally powerful when you need a formula driven, auto-refreshing sort. The ribbon method is ideal when you need a quick, one-time reorder for printing or ad-hoc analysis; the formula method is superior when you want a live view that updates as source data changes.

Built-in Sort dialog—why it shines:

  • No formulas or helper columns needed
  • Sort on unlimited columns, not just two
  • Supports ascending, descending, or custom lists
  • Works inside regular ranges or Excel Tables
    Formula approach—why it shines:
  • Results spill automatically into adjacent cells
  • Sits in dashboards or reports away from raw data
  • Repeats instantly without opening dialogs
  • Combines nicely with FILTER, UNIQUE, and other modern functions

Syntax for a two-column formula sort:

=SORT(A2:D100,1,1,2,1)

Parameters:

  • A2:D100 – the source range
  • 1 – first sort index (column number inside the range)
  • 1 – order (1 for ascending, -1 for descending)
  • 2 – second sort index
  • 1 – order for the second index

Alternative dynamic array using SORTBY (clearer when indexes become cumbersome):

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

Here we sort by column B ascending, then column C descending, producing the entire table in order.

Parameters and Inputs

Regardless of method, you need:

  • A contiguous range or an Excel Table. Blank rows can break the manual Sort dialog, and merged cells block both manual and formula methods.
  • Correct data types: dates stored as real dates, numbers as numbers, and text spelled consistently. Sorting treats “2” (as text) differently from 2 (number).
  • Column indexes for SORT: the positions inside the supplied range. If you select [A2:D100], column 1 is A, column 2 is B, and so on.
  • Sort order flags: 1 for ascending, -1 for descending. With the Sort dialog, you pick from drop-downs.
    Optional inputs: custom lists (e.g., [\"High\",\"Medium\",\"Low\"]) can drive special orders in the dialog. With formulas, you would need a helper column translating those words into numbers.
    Edge cases: duplicate values, blank cells, or non-printing characters can disturb final order. Always TRIM or CLEAN text columns before sorting if data is imported.

Step-by-Step Examples

Example 1: Basic Scenario

Imagine a simple staff list with columns: Last Name, First Name, Department, Hire Date. The requirement is to sort by Department (A→Z) and within each department by Hire Date (oldest first).

  1. Enter sample data in [A1:D11].
  2. Click any single cell inside the data.
  3. On the Data tab, choose Sort (big AZ icon with arrow).
  4. In the dialog:
  • Sort by: Department – Order: A to Z.
  • Add Level.
  • Then by: Hire Date – Order: Oldest to Newest.
  1. Press OK.
    The table instantly reorders. Department groups appear alphabetically, and inside each group the earliest employees are on top—a common HR report.

Why it works: Excel’s Sort dialog evaluates rows left to right by sort priority. If the first key is identical, it proceeds to the next key, ensuring stable ordering. Common variations: change the second order to Newest to Oldest for tenure reports, or add a third level like Last Name for tie-breakers.

Troubleshooting: If nothing happens, confirm you selected a cell in the correct range. If headers get sorted into the data, tick “My data has headers”. Empty rows will stop sorting at the first blank row; delete or fill them.

Example 2: Real-World Application

A regional sales manager tracks monthly sales in a table with columns: Region, Salesperson, Month, Revenue, and Units Sold. She needs a dashboard that always shows the latest data sorted by Region alphabetically and Revenue descending, refreshing automatically as new rows are added by the data entry team.

Setup:

  • Store raw data in a proper Excel Table named tblSales (Insert → Table, “My table has headers”).
  • In another sheet called Dashboard, reserve a starting cell.

Formula steps:

=SORTBY(tblSales, tblSales[Region], 1, tblSales[Revenue], -1)

Explanation: SORTBY fetches the entire table. It sorts by the Region column ascending, then by Revenue descending. Because tblSales is a structured reference, any new rows appended below the table get absorbed automatically, and the formula result “spills” farther down on the dashboard.

Business impact: The manager sends a PDF weekly without touching the dialog. Charts linked to the spilled range adjust instantly. Performance remains smooth because dynamic arrays recalc only when raw data changes.

Advanced tweak: Add a FILTER before SORTBY to show only the current month:

=LET(
     m, EOMONTH(TODAY(),0),
     FILTER(
        SORTBY(tblSales, tblSales[Region],1, tblSales[Revenue], -1),
        tblSales[Month]=m
     )
)

This function combination delivers a live, sorted snapshot for the ongoing month, perfect for management stand-ups.

Example 3: Advanced Technique

You manage 200,000 customer support tickets exported weekly. Columns include Priority, Status, Agent, Open Date, and Close Date. You want to sort by Priority following the custom order High → Medium → Low, and within each Priority sort by Close Date ascending. The dataset’s size causes sluggish performance with normal sorting.

Approach: Power Query (Get & Transform) plus custom list ranking.

  1. Load data via Data → Get Data → From Workbook/CSV.
  2. In Power Query Editor, add a custom column PriorityRank with formula:
  • if [Priority]=\"High\" then 1 else if [Priority]=\"Medium\" then 2 else 3
  1. Sort by PriorityRank ascending, then by Close Date ascending.
  2. Remove PriorityRank (right-click → Remove) so it does not appear later.
  3. Close & Load as a connection only or into a sheet or data model.
  4. Refresh weekly.

Why use Power Query? It keeps the heavy lifting outside the worksheet grid, prevents recalculation bottlenecks, and preserves the “High, Medium, Low” hierarchy without manual custom lists. For even faster performance, load to the data model and analyze with PivotTables or Power BI.

Edge handling: Priority may be blank on unresolved tickets; decide whether to assign rank 4 or filter them out. If Close Date is null, you may need a placeholder far in the future to push unsolved tickets downward.

Tips and Best Practices

  1. Convert ranges to Excel Tables before sorting; tables auto-expand and maintain header recognition.
  2. Use structured references in SORTBY formulas to avoid mis-numbering columns when new fields are inserted.
  3. Combine FILTER, UNIQUE, and SORT/SORTBY for slim, sorted dashboards free of raw data clutter.
  4. Record a macro for repetitive manual sorts; assign it to a button for colleagues unfamiliar with the dialog.
  5. When using custom lists, document them (File → Options → Advanced → Edit Custom Lists) so co-workers replicate the same environment.
  6. Always keep a copy of unsorted data on a hidden sheet or in version control; accidental resorts are the number-one irreversible error for new users.

Common Mistakes to Avoid

  1. Forgetting to select the entire range: sorting only one column breaks row integrity. Use Ctrl+A inside the data before sorting.
  2. Leaving blanks between rows: Excel stops at the first empty line, resulting in partial sorts. Clean or remove blank rows.
  3. Sorting text stored as numbers: “100” (text) will appear before “2” (text) in ascending order. Convert to number format first.
  4. Neglecting to mark “My data has headers”: header labels can slip into row order, skewing analysis. Always double-check the dialog box.
  5. Hardcoding column indexes in formulas: if the dataset layout changes, indexes shift. Use structured references or the COLUMN function for adaptability.

Alternative Methods

MethodProsConsBest For
Ribbon Sort DialogUniversal, unlimited columns, no formulasStatic; must repeat after data changesOne-time reports, quick reordering
SORT / SORTBYDynamic, integrates with other functions, minimal clicksRequires Microsoft 365 / 2021+, spills can collide with existing dataDashboards, auto-updating views
Helper Column + INDEXWorks in older Excel, fully formula-drivenMore complex, needs additional columnsPre-365 environments needing dynamic sort
Power QueryHandles millions of rows, preserves custom hierarchies, scheduled refreshesExtra learning curve, read-only result unless loaded to gridEnterprise scale, ETL pipelines
VBA MacroAutomates dialog actions, compatible with any versionRequires macro security, maintenance overheadRepetitive tasks for users on legacy sheets

Choose the method based on version compatibility, dataset size, and whether the sort must auto-refresh.

FAQ

When should I use this approach?

Use the Sort dialog for ad-hoc tasks. Deploy SORTBY when you want a live result embedded in dashboards. Opt for Power Query or VBA for very large datasets or automated pipelines.

Can this work across multiple sheets?

Yes. With formulas, reference a range on another sheet:

=SORT(Sheet1!A2:D500,2,1,4,-1)

The Sort dialog is sheet-specific, but you can copy sorted data to other sheets. Power Query can merge or append multiple sheets before sorting.

What are the limitations?

SORT and SORTBY spill; they cannot reside where data already exists. All formula methods recalc every workbook change, which may slow down huge files. The dialog fails with merged cells. Power Query output is read-only unless reloaded.

How do I handle errors?

Check for #SPILL! which indicates blocked spill range; clear surrounding cells. If dates sort strangely, ensure they are true dates (not text). In Power Query, use Column Profile to detect data type mismatches.

Does this work in older Excel versions?

Manual Sort works back to Excel 97. SORT, SORTBY, FILTER, and dynamic arrays require Microsoft 365 or Excel 2021. For Excel 2016 and earlier, replicate with helper columns ranking data and wrap INDEX/MATCH around SMALL or RANK.

What about performance with large datasets?

Disable automatic calculation when using formula-heavy sorts on 100,000+ rows. Prefer Power Query, which leverages efficient engines and can load directly into the data model. PivotTables can also aggregate sorted views without rearranging raw rows.

Conclusion

Knowing how to sort by two columns is a deceptively simple yet enormously valuable Excel skill. Whether through the universal Sort dialog, dynamic array formulas, or Power Query, you can reorganize data to uncover insights, streamline reporting, and prevent costly mistakes. Master these techniques, choose the method that matches your version and workload, and you will unlock faster, clearer data stories in every spreadsheet you touch. Next, explore multi-level sorts, custom list orders, and integration with FILTER or PivotTables to elevate your analytical toolbox even further.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.