# SORTBY: Excel Formulas Explained

Hold up, guys! Have you ever spent countless hours trying to sort data in Microsoft Excel? Fret no more! Introducing, SORTBY! The latest Excel formula that has quickly become my favorite. It's straightforward to use and has helped me save an incredible amount of time while dealing with large sets of data.

Before I dive into the details of SORTBY, let's start by saying that it works great with the famous VLOOKUP formula. You've probably heard of it and maybe even used it, right? Chances are you've run into a problem where you need to sort your data based on one column but keep all the remaining columns intact while sorting.

For instance, imagine you're in charge of creating a list of employee names and salary details. You want to sort the list based on salary, but you also want to ensure that the employee names remain intact so that you can identify the highest-paid employees. Wouldn't it be amazing to do that without fear of accidentally deleting any of the relevant data?

This is where SORTBY comes to the rescue. SORTBY is a powerful formula for sorting data that allows you to sort the complete dataset based on a specific column. It's entirely flexible, and one can easily customize the columns they want to sort.

## The Basic Syntax of SORTBY

The syntax of this formula is easy to follow. Everything in between the first parenthesis sets the data you want to sort using the specific column. The comma immediately follows the range, and we then list the column we want to sort by, followed by any optional sorting instructions.

Here's what the formula looks like:

`=SORTBY(range, column, [sort_order], [column2], [sort_order2], ...)`

Did you notice the ellipses there at the end? You can add as many sorting columns as you wish, and the sort order has to match the number of columns you want to sort. The default sort order is ascending, but you can change it by typing "FALSE" instead of "TRUE" to sort the list in descending order.

## Sorting by One Column

Let's go back to the employee salary list example I mentioned earlier. I've created a basic dataset, and it looks like this:

Employee Name Employee Age Job Title Salary
Steve 28 Graphic Designer \$60,000
Ellie 33 Project Manager \$100,000
Dave 25 Marketing Analyst \$55,000
Samantha 30 Web Developer \$80,000
Matthew 29 Software Engineer \$95,000

Now, to sort this data based on Salary, I will enter the following formula:

`=SORTBY(A2:D6, 4, TRUE)`

When I use this formula, the data will be sorted by salary, starting from the highest to the lowest:

Employee Name Employee Age Job Title Salary
Ellie 33 Project Manager \$100,000
Matthew 29 Software Engineer \$95,000
Samantha 30 Web Developer \$80,000
Steve 28 Graphic Designer \$60,000
Dave 25 Marketing Analyst \$55,000

Simple, isn't it? This is why I adore this formula— it's incredibly intuitive and saves me so much time.

## Sorting by Multiple Columns

Okay, let's turn things up a notch. What if you want to sort the list based on two or more columns? For example, you could sort based on age and then name for employees with the same age. No worries, SORTBY can handle that too.

Here's an example:

`=SORTBY(A2:D6, 2, TRUE, 1, TRUE)`

Wait, what? What does that mean?

Oh, you'll love this:

Employee Name Employee Age Job Title Salary
Dave 25 Marketing Analyst \$55,000
Steve 28 Graphic Designer \$60,000
Matthew 29 Software Engineer \$95,000
Samantha 30 Web Developer \$80,000
Ellie 33 Project Manager \$100,000

Can you see how it works? The formula sorts the age column in ascending order first, and then it sorts the employee name column in ascending order, giving us a neat sortout.

## Some Tips and Tricks

Now, before you go sorting all your data right away, let me quickly give you some tips and tricks that will help you navigate the world of SORTBY efficiently.

SORTBY starts with row one. It won't work if your data isn't structured in a table with headers. You can easily create a table quickly by selecting your data and clicking CTRL+T. This creates a table and automatically adds headers to your data.

Always include the headers in your formula. This keeps everything organized and allows you to easily change the columns you want to sort.

### Use the Filter Feature

If your dataset is extensive and you only need to view specific information, you can filter your data to show only what you need. It helps keep things in order.

### Keep an Eye Out for Errors

When working with formulas in Excel, errors are bound to crop up. Ensure you check and verify the number of sorting columns you're using to avoid errors.

## The Bottom Line

SORTBY has become one of my favorite Excel formulas, thanks to its simplicity and versatility. Whether you're working with simple or complex sets of data, this formula is an absolute lifesaver. So go ahead, give it a try. Your data organizing will never be the same.

In conclusion, learning SORTBY could change your life. Okay, maybe not your life, but certainly your experience with Excel. Try it out, and I'm confident you'll never go back to sorting your data the long way.