LAMBDA · Lookup
Two-way lookup LAMBDA
xl.two.way returns the cell where a row label and a column label meet. Dallas in 2026 is 22 on the sample grid.
Syntax =xl.two.way(row_label, col_label, row_headers, col_headers, data)
=LAMBDA(row_label, col_label, row_headers, col_headers, data,
LET(
row_num, XMATCH(row_label, row_headers),
col_num, XMATCH(col_label, col_headers),
INDEX(data, row_num, col_num)
)
)Arguments
| Name | Required | What to pass |
|---|---|---|
| row_label | Required | The label to find down the row headers. |
| col_label | Required | The label to find across the column headers. |
| row_headers | Required | A one-column list aligned with the rows of data. |
| col_headers | Required | A one-row list aligned with the columns of data. |
| data | Required | The value block, without the headers. |
Examples
Dallas sales in 2026
=xl.two.way("Dallas", 2026, A2:A3, B1:C1, B2:C3)Result 22
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | 2025 | 2026 | Label | ||
| 2 | Austin | 10 | 12 | City | Dallas |
| 3 | Dallas | 20 | 22 | Year | 2026 |
| 4 | Value | 22 |
xl.two.way is the intersection lookup. INDEX and XMATCH do it in one line that is easy to get backwards. The row headers are Austin and Dallas. The column headers are 2025 and 2026. Dallas and 2026 meet at 22.
The labels are exact. dallas matches Dallas because XMATCH is not case-sensitive. A year stored as text does not match a numeric header.
Add it to the workbook
Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.two.way, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.two.way(...).
The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.
How it works
XMATCH returns the position of the row label inside the row headers, and the position of the column label inside the column headers. INDEX uses those two positions on the data block only. The headers are not inside data. If you include the header row in the data, every position is off by one.
Limits
The first match wins if a label is repeated. The function does not total a group. GROUP.SUM does that. A missing label is #N/A, which IFNA can replace.