How to Use CONCAT with QUERY using Query function

To use CONCAT with QUERY in Google Sheets, you'll need to use the ARRAYFORMULA function to apply CONCAT to each row returned by the QUERY function. Here's a step-by-step guide on how to do this:

  1. Open a Google Sheet where you want to use CONCAT with QUERY.
  2. Click on a cell where you want the result to be displayed.
  3. Enter the formula using the following structure:

=ARRAYFORMULA(CONCAT(query(A1:B10, "SELECT * WHERE A > 0"), query(C1:D10, "SELECT * WHERE C > 0")))

In this example, the formula will concatenate the results of two QUERY functions that select data from ranges A1:B10 and C1:D10 based on specific conditions. Replace the ranges and conditions in the formula with your own data and requirements.

Here's an example to help you understand how to use CONCAT with QUERY using the ARRAYFORMULA in Google Sheets:

Example

Let's say we have the following data in our Google Sheet:

A         B         C         D
-----------------------------------
Product1  100       Product2  200
Product3  300       Product4  400
Product5  500       Product6  600
Product7  700       Product8  800
Product9  900       Product10 1000

We want to concatenate the Product names with their corresponding prices only if the price is greater than 300.

  1. Choose a cell where you want the result to be displayed, for example, in cell F1.
  2. Enter the following formula in cell F1:

=ARRAYFORMULA(CONCAT(query(A1:B5, "SELECT A WHERE B > 300"), " - ", query(A1:B5, "SELECT B WHERE B > 300")))

This formula will concatenate the product names and their prices in column A and B, only if the price in column B is greater than 300.

  1. Press Enter, and you'll see the following result in the Google Sheet:
F
------------------------
Product3 - 300
Product5 - 500
Product7 - 700
Product9 - 900

You can modify the formula to match your own data and requirements. Remember to replace the ranges, conditions, and CONCAT function with your own values.

Did you find this useful?