# Google Sheets SORTN Function: Syntax, Examples & Tips

- URL: https://betteranalyst.com/google-sheets/sortn-function
- Author: Better Analyst

Formula Bot is now Better Analyst—same account, more powerful analysis.Formula Bot is now Better Analyst—same account and workflows, with more powerful analysis, dashboards, and automation.

[Learn what changed](https://betteranalyst.com/formula-bot-is-now-better-analyst)

The SORTN function returns a specified number of rows from a sorted range, allowing for filtering and deduplication of data.

```
SORTN(range, [n], [display_ties_mode], [sort_column1, is_ascending1], ...)
```

Generate FormulaExplain Formula

One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.

Describe the SORTN you need in plain EnglishGenerate Formula

## Parameters

**`range`**:\
The range of cells that you want to sort and evaluate.

**`n`**:\
The number of items to return from the sorted range. If omitted, all items are returned.

**`display_ties_mode`**:\
An optional parameter that determines how to handle ties in the sorting. It can be set to 0 (default, display all), 1 (display only the first n items), 2 (display the first n unique items), or 3 (display all items with the same value as the nth item).

**`sort_column1`**:\
The column index (1-based) to sort by. This is required if you want to sort the range.

**`is_ascending1`**:\
A boolean value (TRUE or FALSE) that specifies whether to sort the first sort column in ascending order (TRUE) or descending order (FALSE).

## What is a SORTN?

The *SORTN* function in Google Sheets is a powerful tool used to sort a range of data and return a specified number of rows from that sorted data. It is particularly useful for extracting the top or bottom N entries based on specific criteria, making it a great choice for data analysis and reporting. SORTN can handle duplicates and allows for various sorting options, providing flexibility in how you present your data.

In simpler terms, SORTN allows you to organize your data in a meaningful way and focus on the most relevant entries.

## A Practical Example

Imagine you are analyzing sales data for a company and you want to find the top-selling products based on their sales figures.

### Sales Data Table:

| ProductID | ProductName | Sales |
| - | - | - |
| 101 | Widget A | 250 |
| 102 | Widget B | 300 |
| 103 | Widget C | 150 |
| 104 | Widget D | 400 |
| 105 | Widget E | 200 |

You want to extract the top 3 products based on sales.

## SORTN Formula

To achieve this, you would use the SORTN function as follows:

```
=SORTN(A2:C6, 3, FALSE, 3)
```

In this formula:

- `A2:C6` is the range containing your sales data.
- `3` specifies that you want to return the top 3 entries.
- `FALSE` indicates that you want to sort in descending order (highest sales first).
- `3` specifies that the sorting should be based on the third column (Sales).

## Result of the Formula

When you apply the SORTN formula to the Sales Data Table, the output would look like this:

| ProductID | ProductName | Sales |
| - | - | - |
| 104 | Widget D | 400 |
| 102 | Widget B | 300 |
| 101 | Widget A | 250 |

This result shows the top 3 products based on sales figures.

## Why Use SORTN?

SORTN is beneficial because it simplifies the process of sorting and filtering data in Google Sheets. It allows you to quickly identify key entries without the need for complex formulas or manual sorting. Additionally, it can handle duplicates and provides options for sorting in both ascending and descending order, making it a versatile tool for data analysis.

## Key Takeaways:

- **SORTN**: A modern Google Sheets function that sorts data and returns a specified number of rows.
- **Versatile**: Can handle duplicates and allows for sorting in both ascending and descending order.
- **Efficiency**: Simplifies the process of identifying top or bottom entries in your data set.
- **Common Use Cases**: Ideal for sales analysis, performance tracking, and any scenario where you need to focus on key data points.

SORTN is an essential function for anyone working with data in Google Sheets, providing a powerful way to enhance data analysis and reporting capabilities.

Happy spreadsheeting!

## Example use case

You have a list of sales transactions in a table with columns for product names and sales amounts. Use the SORTN formula to quickly display the top 5 products by sales, allowing for easy identification of best-selling items for inventory decisions.

## Need more help with Google Sheets formulas?

Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.

[Create Free Account](https://betteranalyst.com/signup)[Try Formula Generator](https://betteranalyst.com/excel-ai)

## Google Sheets how-to guides

- [How To Lock A Row In Google Sheets](https://betteranalyst.com/google-sheets/how-to-lock-a-row-in-google-sheets)
- [How To Lock Cells In Google Sheets](https://betteranalyst.com/google-sheets/how-to-lock-cells-in-google-sheets)
- [How To Make A Copy Of An Google Sheets Sheet](https://betteranalyst.com/google-sheets/how-to-make-a-copy-of-an-google-sheets-sheet)
- [How To Make A Graph In Google Sheets](https://betteranalyst.com/google-sheets/how-to-make-a-graph-in-google-sheets)
- [How To Make A Histogram In Google Sheets](https://betteranalyst.com/google-sheets/how-to-make-a-histogram-in-google-sheets)
- [How To Make A Line Graph In Google Sheets](https://betteranalyst.com/google-sheets/how-to-make-a-line-graph-in-google-sheets)
- [How To Make A Pie Chart In Google Sheets](https://betteranalyst.com/google-sheets/how-to-make-a-pie-chart-in-google-sheets)
- [How To Make A Table In Google Sheets](https://betteranalyst.com/google-sheets/how-to-make-a-table-in-google-sheets)

## Explore all Google Sheets formulas

Browse our complete library of Google Sheets formula guides

Compare your options

## Decide with evidence, not a sales pitch.

Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.

1. [01ChatGPTOpen a balanced comparison prompt in ChatGPT.](https://chatgpt.com/?prompt=Compare%20Better%20Analyst%20with%20using%20a%20general-purpose%20AI%20assistant%20for%20data%20analysis.%20Evaluate%20spreadsheet%20and%20document%20analysis%2C%20dashboards%2C%20repeatable%20reports%2C%20code%20transparency%2C%20data%20connections%2C%20pricing%2C%20and%20limitations.%20Use%20current%20public%20sources%2C%20distinguish%20verified%20facts%20from%20assumptions%2C%20and%20explain%20which%20types%20of%20users%20each%20option%20fits%20best.)
2. [02ClaudeOpen the same research prompt in Claude.](https://claude.ai/new?q=Compare%20Better%20Analyst%20with%20using%20a%20general-purpose%20AI%20assistant%20for%20data%20analysis.%20Evaluate%20spreadsheet%20and%20document%20analysis%2C%20dashboards%2C%20repeatable%20reports%2C%20code%20transparency%2C%20data%20connections%2C%20pricing%2C%20and%20limitations.%20Use%20current%20public%20sources%2C%20distinguish%20verified%20facts%20from%20assumptions%2C%20and%20explain%20which%20types%20of%20users%20each%20option%20fits%20best.)
3. [03PerplexityResearch the comparison with linked web sources.](https://www.perplexity.ai/search?q=Compare%20Better%20Analyst%20with%20using%20a%20general-purpose%20AI%20assistant%20for%20data%20analysis.%20Evaluate%20spreadsheet%20and%20document%20analysis%2C%20dashboards%2C%20repeatable%20reports%2C%20code%20transparency%2C%20data%20connections%2C%20pricing%2C%20and%20limitations.%20Use%20current%20public%20sources%2C%20distinguish%20verified%20facts%20from%20assumptions%2C%20and%20explain%20which%20types%20of%20users%20each%20option%20fits%20best.)

AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.
