6.9 C
London
Thursday, December 19, 2024
HomeSoftware TutorialsGoogle SheetsGoogle Sheets Query: Select Rows that Contain String

Google Sheets Query: Select Rows that Contain String

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

You can use the following syntax to select rows that contain a specific string using the Google Sheets query function:

=query(A1:C9,select A, B where B contains ‘this’, 1)

This particular query selects columns A and B from the cell range A1:C9 where column B contains the string ‘this’ and the 1 specifies that there is 1 header row at the top of the cell range.

The following examples show how to use this function in practice with the following dataset:

Example 1: Select Rows that Contain a String

We can use the following syntax to select all rows where the Team column contains the string ‘Lak‘:

This query returns the two rows that contain the string ‘Lak’ in the Team column.

Example 2: Select Rows that Do Not Contain a String

We can use the following syntax to select all rows where the Team column does not contain the string ‘Lak‘:

Notice that this returns every row where the team name is not equal to Lakers.

Example 3: Select Rows that Contain One of Several Strings

We can use the following syntax to select all rows where the Team column contains the string ‘Lak‘ or the string ‘Mav‘:

This returns only the rows where the team name is equal to Lakers or Mavericks.

Additional Resources

Google Sheets: How to Sum Values by Category
Google Sheets: How to Query From Another Sheet

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories