The SORTBY function in Excel revolutionizes how we sort data by allowing formula-based, dynamic sorting without altering the source data. Unlike traditional sorting methods, SORTBY maintains your original data structure while creating sorted arrays in separate locations. Available in Excel 365 and later versions, this powerful function helps you create real-time, automatically updating sorted lists.
Sort a Single Column Using SORTBY in Excel
The SORTBY function follows this basic syntax:
=SORTBY(array, by_array1, [sort_order1], [by_array2], [sort_order2],…)
Let’s break down each component:
- array: The range you want to sort
- by_array1: The range that determines the sort order
- sort_order1: Optional. 1 for ascending (default), -1 for descending
- Additional by_array and sort_order pairs for multiple-column sorting
Example 1: Basic Single Column Sort
Let’s sort a list of products by their prices:
Product |
Price |
---|---|
Apple |
1.99 |
Orange |
0.99 |
Banana |
1.49 |
Formula:
=SORTBY(A2:A4, B2:B4)
Result:
Sorted Products |
---|
Orange |
Banana |
Apple |
How Does SORTBY Differ from Regular Sort?
- Formula-Based:
- SORTBY creates a dynamic formula that updates automatically
- Regular Sort physically rearranges data
- Source Data Preservation:
- SORTBY keeps original data intact
- Regular Sort modifies the original dataset
- Real-time Updates:
- SORTBY reflects changes immediately
- Regular Sort requires manual re-sorting
Sort Multiple Columns with SORTBY
Example 2: Primary and Secondary Sort
Consider this employee dataset:
Department |
Last Name |
Salary |
---|---|---|
Sales |
Smith |
50000 |
Marketing |
Jones |
55000 |
Sales |
Brown |
52000 |
To sort by Department (ascending) and then Salary (descending):
=SORTBY(A2:C4, A2:A4, 1, C2:C4, -1)
Result:
Department |
Last Name |
Salary |
---|---|---|
Marketing |
Jones |
55000 |
Sales |
Brown |
52000 |
Sales |
Smith |
50000 |
Creating Custom Sort Orders
Example 3: Mixed Data Types
Consider inventory data:
Item |
Priority |
Stock |
---|---|---|
Laptop |
High |
15 |
Mouse |
Low |
50 |
Keyboard |
Medium |
30 |
To create a custom priority sort (High > Medium > Low):
Stop exporting data manually. Sync data from your business systems into Google Sheets or Excel with Coefficient and set it on a refresh schedule.
Get Started=SORTBY(A2:C4, MATCH(B2:B4,{“High”,”Medium”,”Low”},0))
Practical SORTBY Applications
Sales Data Organization
Example 4: Sales Performance Tracking
Rep |
Region |
Sales |
Commission |
---|---|---|---|
Alice |
North |
50000 |
2500 |
Bob |
South |
75000 |
3750 |
Carol |
East |
60000 |
3000 |
Sort by Sales (descending) and Commission (descending):
=SORTBY(A2:D4, C2:C4, -1, D2:D4, -1)
Common SORTBY Formulas for Business Use
Example 5: Customer Database Sorting
Customer |
Value |
Status |
---|---|---|
ABC Corp |
50000 |
Active |
XYZ Inc |
75000 |
Inactive |
DEF Ltd |
25000 |
Active |
Sort by Status (Active first) then Value (descending):
=SORTBY(A2:C4, B2:B4, -1, EXACT(C2:C4,”Active”), -1)
Next Steps
The SORTBY function transforms how you handle data in Excel, offering dynamic, formula-based sorting that updates automatically as your data changes. Whether you’re managing sales data, organizing inventory, or maintaining customer databases, SORTBY provides a powerful solution for your sorting needs.
Ready to take your Excel data management to the next level? Discover how Coefficient can enhance your spreadsheet capabilities by automatically syncing real-time data from your business systems directly into Excel. Get started with Coefficient today and experience seamless data integration with your Excel workflows.