Get the First or Last Row/Column in a New Google Sheets Table

If you’ve recently started using the new Google Sheets TABLE functionality, you may find the following tips and tricks helpful. This tutorial demonstrates how to extract the first row, last row, first column, and last column of a table in Google Sheets.

These techniques allow you to extract the table header (first row), a category column (typically the first column), and the total row or column (the last row or column).

How does this come in useful in real-life situations?

Imagine you have a header row containing month names. You want to retrieve the total from the last row corresponding to a specific month.

By knowing how to extract the header row and last row of the table, you can use XLOOKUP to find the month name in the header row and retrieve the corresponding value from the total row.

In another scenario, you can look up a name in the first column and return a value from the last column.

Get the First or Last Row in a Table

To get the first row of a table, we can use the CHOOSEROWS function in Google Sheets.

Syntax: CHOOSEROWS(array, [row_num1, …])

Suppose we have a table named “SalesData”.

To get the first row of this table, we can use the following formula:

=CHOOSEROWS(SalesData[#ALL], 1)
First row extraction from a table in Google Sheets

To get the last row from the same table, use the following formula:

=CHOOSEROWS(SalesData[#ALL], -1)

The difference is minimal. The row_num argument in the first formula is 1, whereas in the second formula, it is -1.

Get the First or Last Column in a Table

Once you’ve tried extracting the first or last row in the new Google Sheets table, you can easily extract the first or last column.

What you want to do is replace CHOOSEROWS with CHOOSECOLS.

Syntax: CHOOSECOLS(array, [col_num1, …])

The following formula will help you get the first column in the table named “Purchase”:

=CHOOSECOLS(Purchase[#ALL], 1)
First column extraction from a table in Google Sheets

And the following one will help you find the last column in the same table:

=CHOOSECOLS(SalesData[#ALL], -1)

Additional Tips: Finding the First or Last Cell Address of the New Google Sheets Table

We’ve utilized structured table references in all the above formulas, one of the beauties of the new table feature in Google Sheets.

How can you find the first or last cell address using the table name (structured table references)?

For example, let’s consider the above table named “Purchase”.

The following formula will return the cell address of the very first cell in the “Purchase” table:

=CELL("address", Purchase[#ALL]) // will return $A$1

I’ve utilized the CELL function to return the ID, and the syntax is CELL(info_type, reference).

Where:

  • info_type: “address”
  • reference: Purchase[#ALL]

To get the last cell address of the “Purchase” table, we will adopt a different approach that involves the ADDRESS function:

=ADDRESS(ROWS(Purchase[#ALL]), COLUMNS(Purchase[#ALL])) // will return $E$11

This formula adheres to the syntax ADDRESS(row, column, [absolute_relative_mode], [use_a1_notation], [sheet]).

Where:

  • row: ROWS(Purchase[#ALL]) – it returns the number of rows in the table
  • column: COLUMNS(Purchase[#ALL]) – it returns the number of columns in the table.

Resources

Here are some table-related resources in Google Sheets.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Extract Numbers from Text in Excel with Regex

You can use the REGEXEXTRACT or REGEXREPLACE functions to easily extract numbers from text...

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

How to Use OFFSET and XMATCH Functions Together in Excel

We often use the OFFSET and XMATCH functions together to match a value in...

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

More like this

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

Running Count with Structured References in Google Sheets

Running a count with structured references is achievable in Google Sheets tables using the...

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.