SORT and SORTBY Function in Excel
- V E Meganathan
- Aug 9
- 1 min read
Today we are going to discuss about SORT and SORTBY function in Excel with basic examples.
Our dataset includes the columns Month, Product, and Sales.
Example 1:
The goal is to sort rows by the Sales column in descending order.
=SORT(B3:D16,3,-1)

Example 2:
The goal is to sort rows by the Product column in ascending order and the Sales column in descending order.
=SORT(B3:D16,{2,3},{1,-1})

Example 3:
If sort_order for both columns are same, then we can feed one option as mentioned below.
=SORT(B3:D16,{2,3},1)
This will sort rows based on Product and Sales column in ascending order.
If we ignore sort_order argument, by default it will sort in ascending order.
=SORT(B3:D16,{2,3})
Example 4:
Source data consists of Product wise monthly sales.
Our aim is to sort columns based on Product Name row in ascending order.
=SORT(C2:F9,1,,1)

Example 5:
To arrange the table so that the Month column is ordered from Jan to Dec, the SORTBY function can be used, as it allows for a custom sort order on the Month column.
=SORTBY(B3:D16,MONTH(B3:B16&0),)

Example 6:
We can sort columns based on custom sort order using SORTBY function.
Source data consists of month wise product sales.
Our aim is to sort columns in the order of Jan to Dec.
=SORTBY(C2:F6,MONTH(C2:F2&0),)

Comments