search
HomeSoftware TutorialOffice SoftwareHow to Use the SORTBY Function in Excel

Excel's SORTBY function: a tool for efficient sorting

Microsoft Excel provides a variety of data sorting methods, and the SORTBY function is undoubtedly the simplest and most convenient one. It allows you to dynamically sort data based on multiple arrays while maintaining the integrity of the original data.

SORTBY function syntax

The syntax of the SORTBY function is concise and clear:

 <code>=SORTBY(a,b¹,b²,c¹,c²...)</code>

in:

  • a (required) is the region or array to be sorted;
  • (Required) is the first region or array to sort by;
  • (optional) is the sort order of ;
  • and (optional) are the second arrays sorted by and their sort order, and can support up to 64 such pairs.

Omit the sort order parameter or enter 1 and the data will be arranged in ascending or alphabetical order. Enter -1 and arrange it in descending or inverse alphabetical order.

Parameters a , , , etc. must be compatible in dimensions. For example, if the region selected by the a parameter has 10 rows, the array sorted by must also have 10 rows.

Single-column sorting

Let's see how to sort data by a single column using the SORTBY function.

First, prepare the area in the worksheet for storing the sort results. In this example, we copy-paste the column header into cells G1 to K1 and adjust the font size and alignment of cells G2 to K25 to allow vertical expansion to match the format of the original data.

How to Use the SORTBY Function in Excel

Multi-column sorting

One of the major advantages of the SORTBY function over the SORT function is that you can select multiple variables as the ordering basis.

Continue with the example above, assuming you still want to sort individuals by total points, but want all those who reach the goal to be ranked ahead of those who fail to reach the goal. In other words, you want to sort by the "Met?" column first, and then by the "Points" column.

How to Use the SORTBY Function in Excel

After preparing the cell where the data is stored (including copying the column title and deleting any SORTBY functions entered before), enter in the G2 cell:

 <code>=SORTBY(T_Targets,T_Targets[Met?],-1,T_Targets[Points],-1)</code>

in:

  • T_Targets is an array;
  • T_Targets[Met?] is the first sorted by column in the array;
  • -1 Instruct Excel to sort T_Targets[Met?] in anti-alphabetical order (Y before N);
  • T_Targets[Points] is the second sorted by column;
  • -1 Instruct Excel to sort T_Targets[Points] in descending order.

After pressing Enter, you will get the following results. Note how the sum of points for those who have reached the target is grouped together and displayed in descending order, as are those who have not reached the target.

How to Use the SORTBY Function in Excel

SORTBY is used in combination with FILTER function

The SORTBY function can be used in conjunction with other functions in Excel to further optimize the results. Specifically, we will show how to use SORTBY with FILTER while sorting and filtering the data.

Suppose your goal is to generate a result sorted by the "Points" column, but only display people with a total score of more than 55 points.

After creating the result column header in row 1, enter in cell G2:

 <code>=FILTER(SORTBY(T_Targets,T_Targets[Points],-1),SORTBY(T_Targets[Points],T_Targets[Points],-1)>55)</code>

Then press Enter.

How to Use the SORTBY Function in Excel

Let's break down this formula and learn more about how it works.

How to Use the SORTBY Function in Excel

Comparison between SORT and SORTBY

Both SORT and SORTBY functions are used to reorganize data based on specific values, but they work slightly differently:

feature SORT function SORTBY function
Formula syntax The SORT function allows you to define arrays, index numbers of columns to be sorted, sorted order, and options to sort by row rather than by column. The SORTBY function allows you to define regions, as well as up to 64 sorted arrays - sequential pairing.
Sort level When using SORT functions, you can only sort by one row or one column. When using the SORTBY function, you can sort by up to 64 rows or columns.
Parameter reference The rows or columns to be sorted are referenced by an index number, which means that if you add or delete rows or columns in the original data, this index number may be outdated. Since the array to be sorted can be a named reference (such as column headings), this reference will remain the same even if you add or delete columns in the original data.

In addition to the SORTBY function, another way to create an actionable copy of the dataset (while keeping the original data unchanged) is to create a pivot table. This powerful Excel tool allows you to aggregate and reorganize data in a variety of ways, meaning you can quickly generate calculation results and analyze data without using complex formulas.

The above is the detailed content of How to Use the SORTBY Function in Excel. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to Use the SORTBY Function in ExcelHow to Use the SORTBY Function in ExcelApr 25, 2025 am 01:00 AM

Excel's SORTBY function: a tool for efficient sorting Microsoft Excel provides a variety of data sorting methods, and the SORTBY function is undoubtedly the simplest and most convenient one. It allows you to dynamically sort data based on multiple arrays while maintaining the integrity of the original data. SORTBY function syntax The syntax of the SORTBY function is concise and clear: =SORTBY(a,b¹,b²,c¹,c²...) in: a (required) is the region or array to be sorted; b¹ (Required) is the first region or array to sort by; b² (optional) is the sort order of b¹; c¹ and c² (optional)

How to find and highlight duplicates in ExcelHow to find and highlight duplicates in ExcelApr 24, 2025 am 10:42 AM

This tutorial shows you how to automatically highlight duplicate entries in Excel. We'll cover shading duplicate cells, entire rows, or consecutive duplicates using conditional formatting and a powerful add-in. Last week, we looked at using formulas

How to identify duplicates in Excel: find, highlight, count, filterHow to identify duplicates in Excel: find, highlight, count, filterApr 24, 2025 am 10:06 AM

The tutorial explains how to search for duplicates in Excel. You will learn a few formulas to identify duplicate values or find duplicate rows with or without first occurrences. You will also learn how to count instances of each duplicate

How to lock cells in Excel and unlock certain cells on a protected sheetHow to lock cells in Excel and unlock certain cells on a protected sheetApr 24, 2025 am 09:43 AM

This tutorial explains how to safeguard specific Excel cells from accidental modification or unauthorized editing. It covers locking individual cells, unlocking cells on a protected sheet (with or without a password), and identifying locked/unlocked

How to protect worksheets and unprotect Excel sheet without passwordHow to protect worksheets and unprotect Excel sheet without passwordApr 24, 2025 am 09:27 AM

This tutorial demonstrates how to safeguard Excel spreadsheets with or without passwords, and how to recover access if a password is forgotten. Protecting your worksheets, especially when sharing them externally, is crucial to prevent unauthorized mo

Don't Ignore the Power of F4 in Microsoft ExcelDon't Ignore the Power of F4 in Microsoft ExcelApr 24, 2025 am 06:07 AM

A must-have for Excel experts: the wonderful use of the F4 key, a secret weapon to improve efficiency! This article will reveal the powerful functions of the F4 key in Microsoft Excel under Windows system, helping you quickly master this shortcut key to improve productivity. 1. Switching formula reference type Reference types in Excel include relative references, absolute references, and mixed references. The F4 keys can be conveniently switched between these types, especially when creating formulas. Suppose you need to calculate the price of seven products and add a 20% tax. In cell E2, you may enter the following formula: =SUM(D2 (D2*A2)) After pressing Enter, the price containing 20% ​​tax can be calculated. But,

Count unique and distinct values in Excel with formula or pivot tableCount unique and distinct values in Excel with formula or pivot tableApr 23, 2025 am 11:21 AM

This tutorial shows you how to count unique and distinct values in Excel using formulas and PivotTables. We'll cover counting unique names, text, numbers, and case-sensitive values, as well as handling blank cells. The key difference between "u

COUNT and COUNTA functions to count cells in ExcelCOUNT and COUNTA functions to count cells in ExcelApr 23, 2025 am 10:46 AM

This tutorial provides a concise overview of Excel's COUNT and COUNTA functions, illustrating their use with practical examples. You'll also learn how to leverage COUNTIF and COUNTIFS for counting cells based on specific criteria. Excel excels at nu

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function