Do you need to combine data from multiple cells in Google Sheets?
If so, you can use the CONCAT function to do so. CONCAT lets you combine text from different cells into a single cell.
You can also use the QUERY function to filter and manipulate data in Google Sheets.
BUT: you cannot use CONCAT and QUERY together.
I know I know, it’s probably the saddest news you’ve heard all year.
Don’t worry, in this tutorial you will learn how to simulate this feature.
How to Use CONCAT with QUERY (Google Sheets Query)
The Query function in Google Sheets is the program’s most powerful and flexible feature.
With this versatile tool, you can use data commands to change the data in Google Sheets.
The majority of pivot table functionality may be duplicated by this single function, which takes the place of numerous others.
Although it doesn’t accept delimiter or IgnoreEmpty parameters, the CONCAT function combines text from various ranges and/or strings making it useful to join rows of information together that contains a certain word.
The CONCAT function and the QUERY function cannot be used together, but we can create a different formula that is able to mimic this functionality.
Once ready, we’ll get started by utilizing real-world examples to show you how to use the CONCAT function using Google Sheets Query.
Understand Google Sheets Query
Before using an example, you will need to understand how a Google Sheets Query work.
=QUERY(data, query, [headers])
Google Sheets query requires 3 arguments:
- the data range you want to look at
- the query you want to run, in quotation marks
- an optional number indicating the number of header rows in your data
CONCAT Function using Google Sheets Query
Before we begin we will need a group of data to be used for the Google Sheets query formula.
We want to collect the full names that only by the last name of ‘Brown’.
First, you will need to select a cell to input the formula. In this example, it is E2.
To create a formula to return only the rows that has the last name ‘Brown’, insert the following formula;
=ARRAYFORMULA( SUBSTITUTE( trim(transpose(query(transpose(query(A:C, "select * where C contains 'Brown'")),,COLUMNS(query(A:C, "select * where C contains 'Brown'")))))," ","_"))
Once you press Enter, only the rows with the last name of ‘Brown’ will appear.
The formula will also combine the strings from columns A, B, and C together.
It will look something like this:
The data returned from the Query function will not be formulated. You can edit the data to your own preferences.
That’s all there is to it. You are welcome to copy the example spreadsheet below to see how it is done. The most crucial lesson is to enjoy yourself while doing it.
Example Spreadsheet: Make a copy of the example spreadsheet
In this tutorial, I covered how to use the CONCAT function using Google Sheets Query. Want more? Check out all the Google Sheets Tutorials.