CHOOSEROWS
Return specific rows from an array or range, in any order you choose.
Spreadsheet editor
Spreadsheet editor
Syntax
=CHOOSEROWS(array, row_num1, [row_num2], ...)
Returns: Array Arguments
| Argument | Required | Description |
|---|---|---|
| array | Yes | The source range or array that contains the rows you want to return. |
| row_num1 | Yes | The position of the first row to return. Count from 1 at the top, or use a negative number to count from the bottom. |
| row_num2 | No | Additional row positions to return, listed in the order you want them. |
About
Use CHOOSEROWS when you need specific rows by position, such as the top record, the last entry, or a custom pick like rows 1, 5, and 9. You can repeat a row number to return the same row twice, and you can reverse the order just by listing positions backwards. Negative numbers count from the bottom, so -1 grabs the last row, which is great when the number of rows can grow or shrink.
CHOOSEROWS pairs well with other dynamic array functions. Run FILTER first to keep only the rows that match a condition, or use SORT to order rows before you trim them down. To grab columns by position instead of rows, see CHOOSECOLS, and to pull rows from the very top or bottom of a table, see TAKE.
Examples
Grab the last rows with negative numbers
Spreadsheet editor
Build a top-3 leaderboard with SORT
Spreadsheet editor
Watch out for
Counting from worksheet row numbers
People assume row_num matches the row numbers on the sheet, so a table starting on row 5 feels like it should use 5.
→ Row numbers are positions inside the array you pass in, not sheet rows. If your array starts on row 5, its first row is still 1 inside CHOOSEROWS.
Asking for a row that does not exist
Using a number larger than the row count, or 0, returns a #VALUE! error and nothing spills.
→ Keep each row_num between 1 and the number of rows in the array (or use negative numbers within the same range). Use ROWS to check how many rows your array has.
Output blocked by existing data
CHOOSEROWS spills its result, so if a cell in the output area already has data you get a #SPILL! error.
→ Clear the cells below the formula so the array has empty space to expand into.