← All how-to recipes

How to look up a value with two criteria (multi-condition lookup)

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

Return a value that matches on two columns at once, e.g. the amount for Region = North AND Quarter = Q2.

The formula

AppFormulaNotes
Excel=XLOOKUP("North|Q2",A2:A6&"|"&B2:B6,C2:C6)Excel 365; concatenate the keys.
Google Sheets=XLOOKUP("North|Q2",ARRAYFORMULA(A2:A6&"|"&B2:B6),C2:C6)Executed 2026-08-30: the unwrapped =XLOOKUP("North|Q2",A2:A6&"|"&B2:B6,C2:C6) returned #VALUE! in Google Sheets against 250 in LibreOffice. The concatenated key A2:A6&"|"&B2:B6 is an array expression, and Google Sheets does no implicit array evaluation inside a scalar function’s arguments, so ARRAYFORMULA has to force it; =FILTER(C2:C6,A2:A6="North",B2:B6="Q2") sidesteps the whole issue. Both are documented Sheets syntax, carrying no executed result of their own.
LibreOffice Calc=XLOOKUP("North|Q2",A2:A6&"|"&B2:B6,C2:C6)LibreOffice 25.8 (XLOOKUP added 24.8).

How it works

Concatenate the two key columns (A&"|"&B) into a single combined key, then XLOOKUP that combined key. 'North|Q2' matches row 3, returning 250. The pipe separator avoids accidental collisions between key parts.

The Google Sheets alternative

Google Sheets needs different syntax for this task. The formula below is Sheets-specific — it was executed in Google Sheets (2026-08-30) against the same sample data as the worked example, and the value beside it is what Google returned. The LibreOffice column reads n/a because the formula is outside LibreOffice’s dialect, so there is nothing of ours to report there.

FormulaWhat it doesReturned by LibreOffice 25.8.7.3Returned by Google Sheets (executed 2026-08-30)
=XLOOKUP("North|Q2",ARRAYFORMULA(A2:A6&"|"&B2:B6),C2:C6)ARRAYFORMULA around the concatenated key A2:A6&"|"&B2:B6 n/a (Sheets-only formula) 250 Google Sheets alternative (executed 2026-08-30)
NOTE: written with the PLAIN function name; the LibreOffice reference run executed the _xlfn. storage form of this formula, so the two runs are not byte-identical inputs

Verified, not just documented

We ran =XLOOKUP("North|Q2",A2:A6&"|"&B2:B6,C2:C6) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 250 — 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. For the worked example Google Sheets returned #VALUE!, which is not what LibreOffice returned (250) — both values are shown as each engine produced them, and the disagreement itself is the finding. A further 1 row is a Google Sheets alternative: Sheets-specific syntax, executed in Google Sheets only, so the LibreOffice column reads n/a for it. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run Excel.

Functions used

XLOOKUP · ARRAYFORMULA — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons