# Google Sheets ARRAY_CONSTRAIN Function: Syntax, Examples & Tips

- URL: https://betteranalyst.com/google-sheets/array_constrain-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 ARRAY\_CONSTRAIN function limits the size of an array by specifying the number of rows and columns to return from the original array.

```
ARRAY_CONSTRAIN(input_range, num_rows, num_cols)
```

Generate FormulaExplain Formula

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

Describe the ARRAY\_CONSTRAIN you need in plain EnglishGenerate Formula

## Parameters

**`input_range`**:\
The range of cells that you want to constrain to a specific number of rows and columns.

**`num_rows`**:\
The number of rows to include in the constrained output from the `input_range`.

**`num_cols`**:\
The number of columns to include in the constrained output from the `input_range`.

## What is ARRAY\_CONSTRAIN?

The *ARRAY\_CONSTRAIN* function in Google Sheets is a useful tool that allows you to limit the size of an array or range to a specified number of rows and columns. This function is particularly beneficial when you want to work with a subset of data without altering the original dataset. It helps in creating dynamic ranges that can be used in other formulas or for data visualization.

In simpler terms, ARRAY\_CONSTRAIN enables you to take a larger dataset and restrict it to a smaller, more manageable size, making it easier to analyze or present.

## A Practical Example

Imagine you have a dataset of sales data that includes multiple columns, but you only want to display the top 5 sales records.

### Sales Data Table:

| SaleID | ProductName | Quantity | Price | Total |
| - | - | - | - | - |
| 1 | Widget A | 3 | 25.00 | 75.00 |
| 2 | Widget B | 5 | 30.00 | 150.00 |
| 3 | Widget C | 2 | 15.00 | 30.00 |
| 4 | Widget D | 4 | 20.00 | 80.00 |
| 5 | Widget E | 1 | 50.00 | 50.00 |
| 6 | Widget F | 6 | 10.00 | 60.00 |

You want to display only the top 5 sales records based on the Total column.

## ARRAY\_CONSTRAIN Formula

To achieve this, you would use the ARRAY\_CONSTRAIN function as follows:

```
=ARRAY_CONSTRAIN(SalesData!A:E, 5, 5)
```

In this formula:

- `SalesData!A:E` is the range of the original sales data.
- `5` is the number of rows you want to include in the constrained array.
- `5` is the number of columns you want to include in the constrained array.

## Result of the Formula

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

| SaleID | ProductName | Quantity | Price | Total |
| - | - | - | - | - |
| 1 | Widget A | 3 | 25.00 | 75.00 |
| 2 | Widget B | 5 | 30.00 | 150.00 |
| 3 | Widget C | 2 | 15.00 | 30.00 |
| 4 | Widget D | 4 | 20.00 | 80.00 |
| 5 | Widget E | 1 | 50.00 | 50.00 |

The ARRAY\_CONSTRAIN function effectively limits the output to just the top 5 records from the original dataset.

## Why Use ARRAY\_CONSTRAIN?

ARRAY\_CONSTRAIN is beneficial because it allows you to focus on a specific portion of your data without modifying the original dataset. This can be particularly useful for reporting, data analysis, or when creating charts and graphs. It simplifies the process of working with large datasets by allowing you to create dynamic ranges that can be easily referenced in other formulas.

## Key Takeaways:

- **ARRAY\_CONSTRAIN**: A Google Sheets function that limits the size of an array or range to a specified number of rows and columns.
- **Dynamic Ranges**: Helps create dynamic ranges for analysis or visualization without altering the original data.
- **Data Management**: Simplifies working with large datasets by allowing you to focus on specific portions of the data.
- **Common Use Cases**: Ideal for reporting, data analysis, and any scenario where you need to present a subset of data.

ARRAY\_CONSTRAIN is an essential function for anyone working with data in Google Sheets, providing a powerful way to enhance data management and reporting capabilities.

Happy spreadsheeting!

## Example use case

You have a sales report with multiple columns, but you only want to display the top 10 sales figures. Use ARRAY\_CONSTRAIN to limit the output to the first 10 rows of your sorted sales data, making it easy to focus on the highest performers without clutter.

## 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 Make A Table In Google Sheets](https://betteranalyst.com/google-sheets/how-to-make-a-table-in-google-sheets)
- [How To Merge Cells In Google Sheets](https://betteranalyst.com/google-sheets/how-to-merge-cells-in-google-sheets)
- [How To Multiply In Google Sheets](https://betteranalyst.com/google-sheets/how-to-multiply-in-google-sheets)
- [How To Password Protect An Google Sheets File](https://betteranalyst.com/google-sheets/how-to-password-protect-an-google-sheets-file)
- [How To Remove Blank Rows In Google Sheets](https://betteranalyst.com/google-sheets/how-to-remove-blank-rows-in-google-sheets)
- [How To Remove Duplicates In Google Sheets](https://betteranalyst.com/google-sheets/how-to-remove-duplicates-in-google-sheets)
- [How To Separate Names In Google Sheets](https://betteranalyst.com/google-sheets/how-to-separate-names-in-google-sheets)
- [How To Sort In Google Sheets](https://betteranalyst.com/google-sheets/how-to-sort-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.
