Google Sheets Tips

QUERY with CONCATENATE in Google Sheets: how to concatenate two columns

The QUERY language cannot join columns: select A & B returns an error. This guide shows the three ways that work, worked on one campaign export: concatenate the columns before the query, join the columns of the query result, or collect the result into one cell, plus one label per campaign (channel, market and month) for a spend report and the simpler formulas for cases where no QUERY is needed.

Google Sheets TipsVadym Kramarenko11 min read

QUERY with CONCATENATE in Google Sheets: how to concatenate two columns

The QUERY language in Google Sheets has no concatenation operator: "select B & C" returns #VALUE!. To concatenate two columns in a QUERY, join them before the query, inside curly braces, and wrap the formula in ARRAYFORMULA:

=ARRAYFORMULA(QUERY({A2:A11 & " - " & B2:B11, D2:D11}, "select Col1 where Col2 > 2000", 0))

The formula returns one column, channel and market joined with a dash, for the campaigns that spent more than 2,000.

Every example on this page works on one campaign export and one question a CMO asks before the budget meeting: one label per campaign: channel, market and month. Ad platforms export them as separate columns; a spend or sales report needs one value, such as Paid social | DE | 2026-11, to group by. The label is one formula, built in the section on where this shows up in a report. The sheet:

Column Holds
A Channel name: Paid search, Paid social or Email
B Market code: DE, UK or FR, and an empty cell in row 9, where the campaign was set up without one
C Month: a date, the first day of the month the money was spent
D Spend
E Revenue

There are ten campaigns, from 2026-10 and 2026-11, in rows 2 to 11, with the headers in row 1. Two of them, in rows 8 and 11, share a channel, a market and a month.

Google Sheets with a campaign export in A1:E11 (channel, market, month, spend, revenue) and the formula =ARRAYFORMULA(QUERY({A2:A11 & “ - “ & B2:B11, D2:D11}, “select Col1 where Col2 > 2000”, 0)) in G2, returning five joined values such as Paid search - DE for the campaigns with spend above 2,000

There are three ways to combine the two functions, depending on where the join happens:

You need Approach
A joined column that the query can also filter or sort by Concatenate before the query
The columns of the query result joined row by row Join after the query
All rows of the query result in one cell TEXTJOIN around the query

Reading to get this done?

What each function does

What each function does

=QUERY(data, query, [headers])

QUERY filters, sorts and summarizes a range with a query string. Its language can select columns, compare them and aggregate them, but it cannot build a new text value from two columns.

=CONCATENATE(string1, [string2, ...])

CONCATENATE joins text. The ampersand (&) does the same and is shorter: =A2 & " " & B2.

Concatenate before the query

Concatenate before the query

Build the joined column first and hand it to QUERY as part of the data:

=ARRAYFORMULA(QUERY({A2:A11 & " - " & B2:B11, D2:D11}, "select Col1 where Col2 > 2000", 0))

  • {A2:A11 & “ - “ & B2:B11, D2:D11}: a table built in the formula. Its first column is the joined text, channel and market; its second column is the spend.
  • “select Col1 where Col2 > 2000”: when the data is built in curly braces and not taken from the sheet, columns are named Col1, Col2 and so on, in the order they appear in the braces. Letters such as A and D do not work here.
  • 0: the data has no header row.
  • ARRAYFORMULA: makes the ampersand work on the whole range. Without it the formula returns an error.

On the export it returns five values, from Paid search - DE to Paid search - UK. Pro tip: because the joined column is part of the data, the query can use it like any other column: sort by it with order by Col1, or filter it with where Col1 contains 'DE'.

Hand this to your AI

You want QUERY to return first and last name as one column, and select A & B only returns an error.

Paste this into your AI assistant. It writes the formula for your own range that joins the columns before or after the QUERY, or collects the result into one cell.

The prompt

combine two columns of my range into one in a QUERY result, filtered by my condition, and give me the version without QUERY if it is simpler

Join the columns of the query result

Join the columns of the query result

The second way runs the query first and joins its columns afterwards.

All columns of each row

This formula joins the cells of every row with a space:

=TRANSPOSE(QUERY(TRANSPOSE(A2:B11),,6^6))

It returns the channel and the market of each campaign in one cell, for example Paid search DE in the first row. It relies on the third argument of QUERY, the number of header rows. When a range has several header rows, QUERY merges them into one, with a space between the values. The formula turns that into a join:

  • TRANSPOSE(A2:B11): flips the range, so each row becomes a column.
  • QUERY(…, , 6^6): no query string, and 6^6 (46,656) header rows, more than the data has. QUERY treats every row as a header and merges each column into a single cell.
  • TRANSPOSE: flips the result back into a column.

Only the rows that match a condition

Put a query inside to filter the rows first. This nested formula keeps the rows with DE in column B, joins channel and market, and replaces the spaces with underscores:

=ARRAYFORMULA(SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(QUERY(A2:B11, "select * where B = 'DE'", 0)),,COLUMNS(QUERY(A2:B11, "select * where B = 'DE'", 0))))), " ", "_"))

  • QUERY(A2:B11, “select * where B = ‘DE’”, 0): the five campaigns in the DE market.
  • TRANSPOSE and the outer QUERY: the header-row join from the previous example.
  • TRIM: removes extra spaces.
  • SUBSTITUTE(…, “ “, “_”): replaces every space with an underscore, including the spaces inside the channel names in column A: Paid search DE becomes Paid_search_DE.

A shorter formula for the same job uses BYROW, which applies a function to each row of the query result, and TEXTJOIN, which takes the separator as an argument:

=BYROW(QUERY(A2:B11, "select * where B = 'DE'", 0), LAMBDA(row, TEXTJOIN("_", TRUE, row)))

Here the separator goes only between the columns, and the channel names keep their spaces: Paid search_DE.

Collect the query result into one cell

Collect the query result into one cell

To list the values a query returns in a single cell, wrap the query in TEXTJOIN:

=TEXTJOIN(", ", TRUE, QUERY(A2:D11, "select B where D > 2000", 0))

  • “, “: the separator.
  • TRUE: skip empty cells.
  • QUERY(…): the markets of the campaigns whose spend is above 2,000.

The result is one cell: DE, UK, DE, DE, UK. Wrap the query in UNIQUE to list each market once, =TEXTJOIN(", ", TRUE, UNIQUE(QUERY(A2:D11, "select B where D > 2000", 0))), and the cell reads DE, UK. JOIN works the same way for a single column: =JOIN(", ", QUERY(A2:D11, "select B where D > 2000", 0)).

Where this shows up in a report

Where this shows up in a report

The CMO’s label is the first way above with three columns joined instead of two, and a group by on it:

=ARRAYFORMULA(QUERY({A2:A11 & " | " & IF(B2:B11="", "No market", B2:B11) & " | " & TEXT(C2:C11, "yyyy-mm"), D2:E11}, "select Col1, sum(Col2), sum(Col3) group by Col1 label Col1 'Label', sum(Col2) 'Spend', sum(Col3) 'Revenue'", 0))

Google Sheets with the campaign export in A1:E11 and a QUERY in G1 that joins channel, market and month into one label and groups by it, returning a header row and nine labels with spend and revenue, among them Paid search | No market | 2026-11 with 900 and 1,350 and Paid social | DE | 2026-11 with 2,850 and 4,590

  • TEXT(C2:C11, “yyyy-mm”): the month column holds dates, and a date joined with & turns into its serial number. TEXT writes it as 2026-11.
  • IF(B2:B11=“”, “No market”, B2:B11): the campaign in row 9 has no market. Without the IF its label would have nothing between the two separators, which is easy to miss in a list of nine. With it, the label says what is missing.
  • label Col1 ‘Label’, sum(Col2) ‘Spend’, …: names the output columns. With an aggregate, QUERY writes a header row even when the data has none (0), and without label QUERY names the columns itself, with “sum” in front of the totals.
  • group by Col1: campaigns with the same label are added up. The ten campaigns become nine lines, because Paid social | DE | 2026-11 holds two campaigns: 2,850 spent, 4,590 back.

The spend on the nine lines adds up to 18,050, the same as column D, so nothing was dropped on the way. The line to look at is Paid search | No market | 2026-11: 900 spent, 1,350 back, and no market to hold it against. The decision to write next to that number is who owns it until the campaign is renamed in the ad account. Until then it stays its own line and is not added to the DE or UK budget.

When you do not need QUERY

When you do not need QUERY

If there is nothing to filter, sort or aggregate, the join is simpler without QUERY.

ARRAYFORMULA with an ampersand

=ARRAYFORMULA(A2:A11 & "_" & B2:B11)

Google Sheets with the formula =ARRAYFORMULA(A2:A11 & “” & B2:B11) in G2 returning the channel and the market joined with an underscore for all ten campaigns, and Paid search for row 9, where the market is empty

One formula in the first cell joins the two columns for every row in the range. Row 9 returns Paid search_ because its market is empty; the ampersand joins what is there. See the guide to ARRAYFORMULA for how this works.

CONCATENATE for one row

=CONCATENATE(A2, " ", B2)

CONCATENATE joins the cells you list, with the separators you put between them. In row 2 the formula =CONCATENATE(A2, “ “, B2) returns Paid search DE. Copy the formula down for the other rows.

IF with CONCATENATE for a condition

=IF(B2="DE", CONCATENATE(B2, "_", A2), "")

IF joins the market and the channel only where the market is DE, for example DE_Paid search, and leaves the other cells empty. Copied down to row 11, it fills five of the ten rows.

ARRAYFORMULA with CONCAT

=ARRAYFORMULA(CONCAT(A2:A11, B2:B11))

CONCAT joins exactly two values and has no room for a separator, so the result runs together: Paid searchDE. Use the ampersand when you need a separator.

Errors and how to fix them

Errors and how to fix them

⚠️ Error: #VALUE! for a query such as "select B & C".

✅ Solution: The query language has no & operator and no CONCATENATE. Join the columns before the query, in curly braces, or after it.

⚠️ Error: The formula with curly braces returns an error.

✅ Solution: Check two things. The formula has to be wrapped in ARRAYFORMULA, and the query has to use Col1, Col2 instead of column letters.

⚠️ Error: Formula parse error after pasting a formula from a web page or a document.

✅ Solution: The quotes were replaced with typographic ones (“ ” or ‘ ’). Retype them as straight quotes in the formula bar.

⚠️ Error: The month in a joined label shows as a number, such as Paid search | DE | 46296.

✅ Solution: It is Google Sheets 101 and it catches everyone once: a date is a number, and the ampersand joins the number. Wrap the date column in TEXT, for example TEXT(C2:C11, "yyyy-mm").

⚠️ Error: The joined values have double or trailing spaces.

✅ Solution: Empty cells in the range can leave a space behind. Wrap the result in TRIM, or fill the empty cells with a value, as the IF in the report formula does.

Related Google Sheets functions

Functions that are often used next to QUERY and CONCATENATE, each with its own guide:

  • QUERY with IMPORTRANGE: Queries a range that lives in another spreadsheet.
  • QUERY date filtering: Filters rows by a date or a date range inside a QUERY formula.
  • FILTER: Extracts the rows that meet a condition, without a query string.
  • VLOOKUP: Finds a value in a table by a key.
  • XLOOKUP: A lookup that can search in any direction.
  • Pivot tables: Summarize a table by category without formulas.
  • REPT: Repeats text a set number of times.
  • LEFT/RIGHT/MID: Extracts a set number of characters from the start, end or middle of a text string.

Joined keys are a sign that the data needs a better source

Joined keys are a sign that the data needs a better source

Columns are usually concatenated in a sheet for one of two reasons: to build a label for a report, or to build a key, such as campaign plus date or product plus market, that lets one export be matched with another. The second case is a join done by hand, and it breaks as soon as one of the exports changes its naming. The formula is exact; the rows may not be: a campaign with no market or a channel spelled two ways gives a label that is joined correctly and still wrong.

The OWOX Data Marts extension for Google Sheets covers that half. A data analyst publishes a Data Mart (a table or an SQL query in your data warehouse, with the definitions the team agreed, such as which column holds the market and which month a cost belongs to) and makes it available for reports. In Sheets you open the extension, pick the Data Mart, tick the columns you want and run it. The rows land in a tab, ready for your formulas.

Google Sheets with the OWOX Data Marts extension open beside an ad spend table: the Unified Ad Spend Data Mart, nine of fourteen columns ticked and a Save & Run button – the rows in the sheet come from a governed Data Mart, not a pasted export

What changes for the person who maintains the sheet:

  • Refresh replaces re-export. Refresh current report in the extension menu re-runs the same pull, and a scheduled refresh keeps the tab current without anyone touching it.
  • The source is written on the sheet. The header cell of an imported tab carries a note with the Data Mart it came from, the time of the import and a link to the report.
  • No SQL and no data warehouse access needed. The analyst decides which Data Marts and columns are available. You choose from that list.

The extension does not write or change the analyst’s SQL. When the match between two sources is made there once, the sheet receives the columns already side by side, and concatenation goes back to being a formatting task. The extension comes with the OWOX Cloud plans of OWOX Data Marts; spreadsheet reporting describes both ways data reaches a sheet.

Hand this to your AI

You want QUERY to return first and last name as one column, and select A & B only returns an error.

Paste this into your AI assistant. It writes the formula for your own range that joins the columns before or after the QUERY, or collects the result into one cell.

The prompt

combine two columns of my range into one in a QUERY result, filtered by my condition, and give me the version without QUERY if it is simpler

FAQ

Frequently Asked Questions

Can CONCATENATE be used inside a QUERY statement?

No. The QUERY language has no concatenation operator, so a query string such as "select A & B" returns an error. Join the columns before the query instead, inside curly braces: on a campaign export with the channel in column A, the market in column B and the spend in column D, =ARRAYFORMULA(QUERY({A2:A11 & " - " & B2:B11, D2:D11}, "select Col1 where Col2 > 2000", 0)) returns labels such as Paid search - DE for the campaigns that spent more than 2,000. You can also join the columns of the result afterwards with TEXTJOIN or the ampersand.

Why does my attempt to concatenate QUERY results return an error?

There are four usual causes. An ampersand or CONCATENATE is written inside the query string, which the query language does not support. A formula with curly braces is not wrapped in ARRAYFORMULA. Column letters are used where Col1 and Col2 are required, because the data was built in braces. Or the quotes were pasted from a document as typographic quotes. If the formula works but a month in the label shows as a number such as 46296, the date column needs TEXT(C2:C11, "yyyy-mm").

Can I use QUERY to fetch data from multiple columns and then concatenate them in 1 column?

Yes. Join the columns into one, then let QUERY work on the joined column. For a label per campaign made of channel, market and month, =ARRAYFORMULA(QUERY({A2:A11 & " | " & B2:B11 & " | " & TEXT(C2:C11, "yyyy-mm"), D2:D11}, "select Col1, sum(Col2) group by Col1 label Col1 'Label', sum(Col2) 'Spend'", 0)) returns a header row and then one row per label, such as Paid social | DE | 2026-11, with its total spend. To join the columns of a query result row by row instead, use BYROW with TEXTJOIN around the QUERY.

How can I concatenate rows returned by a QUERY function into a single cell?

Wrap the QUERY in TEXTJOIN and give it a separator. On a campaign export with the market in column B and the spend in column D, =TEXTJOIN(", ", TRUE, QUERY(A2:D11, "select B where D > 2000", 0)) returns DE, UK, DE, DE, UK in one cell. TRUE skips empty cells. To list each market once, put UNIQUE around the QUERY, and the cell reads DE, UK.

Who wrote this

Vadym Kramarenko

Vadym Kramarenko Growth Marketing Manager

Vadym Kramarenko is a Growth Marketing Manager at OWOX, where he drives user acquisition and product-led growth strategies. He hosts the OWOX podcast, interviewing analytics professionals about data-driven marketing, attribution, and reporting best practices. Vadym specializes in turning complex analytics concepts into practical, actionable marketing frameworks.