Get the First Text Value in a Range in Google Sheets

Published on

You can use several lookup functions to get the first text value in a range in Google Sheets. Additionally, you can find the first text value and retrieve the corresponding value from another range.

Here’s the simplest way to achieve this in Google Sheets:

=SINGLE(FILTER(range, ISTEXT(range)))

Replace range with the range from which you want to extract the first text value. This can be either a row or a column reference.

If you want to find the first text value in one range and get the corresponding value from another range, replace the filter range with the result range, and the second range (within ISTEXT) with the lookup range.

There are alternative solutions as well. We will explore those after an example.

Example of Getting the First Text Value

Consider the sample data where column B contains fruit names and column C contains available quantities. Some cells in C contain text, such as “Pending.”

The following formula will extract the first text value in C2:C:

=SINGLE(FILTER(C2:C, ISTEXT(C2:C)))

As per the sample data, this will return “Pending” in cell C6.

Example of Extracting the First Text Value in a Range in Google Sheets

Here’s how the formula works:

  • The ISTEXT function returns an array of TRUE or FALSE values, where TRUE represents text and FALSE represents other values.
  • The FILTER function extracts all values corresponding to TRUE. In short, the FILTER function returns all text values.
  • The SINGLE function (currently undocumented) returns only the first value from the filtered array.

Note: SINGLE is equivalent to using the + sign in front of the formula, like this: =+FILTER(C2:C, ISTEXT(C2:C)).

If you want to get the value from column B corresponding to the first text in column C, replace the filter range C2:C with B2:B. Here’s that formula:

=SINGLE(FILTER(B2:B, ISTEXT(C2:C)))

This will return “Grapes” from cell B6.

The formula works equally well for rows or columns. Simply adjust the references as needed.

Alternative Lookup Solutions

Here are two other great options for extracting the first text value in a range:

1. INDEX-XMATCH with ISTEXT

In this formula, we’ll use the ISTEXT function to return an array of TRUE/FALSE values:

=INDEX(C2:C, XMATCH(TRUE, ISTEXT(C2:C)))
  • The XMATCH function finds the position of the first TRUE in the array returned by ISTEXT and returns its position.
  • The INDEX function then uses that position to extract the value from C2:C.

Syntax: INDEX(reference, [row], [column])

In this formula, the reference is C2:C and the row is determined by the XMATCH function, i.e., XMATCH(TRUE, ISTEXT(C2:C)).

If you want to find the first text value in C2:C and return the corresponding value from B2:B, replace the reference C2:C with B2:B.

If you’re wondering whether you need to specify the XMATCH function in the column argument (when working with rows), the answer is no. When referring to a single row or column, the function automatically adapts to either a row (if the range is vertical) or a column (if horizontal).

2. XLOOKUP and ISTEXT Combo

Here’s another formula to get the first text value from a range:

=ARRAYFORMULA(XLOOKUP(TRUE, ISTEXT(C2:C), C2:C))

In this case, the role of ISTEXT is the same as before: it returns an array of TRUE/FALSE values corresponding to text and non-text values.

The XLOOKUP function uses this array as the lookup range. The search key is TRUE, and the result range is C2:C. The formula returns the first matching value from C2:C.

Syntax: XLOOKUP(search_key, lookup_range, result_range)

If you want the corresponding value in column B, replace C2:C (the result range) with B2:B.

Resources

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.

Get the First Numeric Value in a Range in Google Sheets

When working with data in Google Sheets, you may need to get the first...

How to Create a Case-Sensitive Pivot Table in Excel

As you may know, Pivot Tables in Excel are case-insensitive by default. To create...

How to Create a Case-Sensitive Pivot Table in Google Sheets

To create a case-sensitive pivot table in Google Sheets, we will use a helper...

Marking Case-Sensitive Unique Values in Excel

Marking case-sensitive unique values provides several benefits compared to merely extracting them in an...

More like this

Get the First Numeric Value in a Range in Google Sheets

When working with data in Google Sheets, you may need to get the first...

How to Create a Case-Sensitive Pivot Table in Google Sheets

To create a case-sensitive pivot table in Google Sheets, we will use a helper...

Highlight Upcoming Birthdays in Google Sheets

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

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.