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.

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

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.