← All how-to recipes

How to concatenate cells that meet a condition (TEXTJOIN IF)

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Build a comma-list from only the rows that match — the products in one order, the names on one team.

The formula

AppFormulaNotes
Excel (desktop)=TEXTJOIN(", ",TRUE,IF(A2:A6="East",B2:B6,""))The IF blanks non-matching rows; TEXTJOIN skips the blanks. In older Excel, enter with Ctrl+Shift+Enter.
Google Sheets=TEXTJOIN(", ",TRUE,IF(A2:A6="East",B2:B6,""))Identical; =TEXTJOIN(", ",TRUE,FILTER(B2:B6,A2:A6="East")) is cleaner.
LibreOffice Calc=TEXTJOIN(", ",TRUE,IF(A2:A6="East",B2:B6,""))Works in 25.8+; the FILTER version needs 24.8+.

How it works

The IF runs over the whole range and returns each B value where the condition is true and "" where it isn't, producing an array like {"apple","","cherry","date"}; TEXTJOIN with its ignore-empty argument set to TRUE then glues only the real values together: "apple, cherry, date" (the West row is dropped). On modern versions TEXTJOIN(", ",TRUE,FILTER(B2:B6,A2:A6="East")) reads more clearly and does the same. This is the standard 'list all the X for each Y' pattern for turning rows into a summary cell; add more conditions by multiplying them inside the IF or FILTER.

Verified, not just documented

We ran =TEXTJOIN(", ",TRUE,FILTER(B2:B5,A2:A5="East")) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned apple, cherry, date — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned apple, cherry, date for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

TEXTJOIN · IF — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons