Use Excel XLOOKUP to Retrieve Data from Previous Matching Rows
Question details
Find a formula that returns data from a previous row with matching direction and identifying values.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains direction and identifying values in columns D, F, and G, and the user wants to retrieve data from a matching earlier row.
- Observed behavior
- The desired result is data from the most recent previous row where all three values match, optionally returning several adjacent columns.
Check that columns D, F, and G contain the matching criteria and that the data begins on row 2. Confirm that your Excel version supports XLOOKUP, and adjust the column references if your worksheet uses a different layout.
Find the most recent previous match with XLOOKUP
Use this formula to match all three criteria and search earlier rows from bottom to top.
The formula searches only rows above row 26, so it cannot return the current row. Testing each criterion separately also avoids ambiguous matches that can occur when values are joined into one key.
Select an empty result cell such as P26 and enter =XLOOKUP(1,(D$2:D25=D26)*(F$2:F25=F26)*(G$2:G25=G26),K$2:K25,"Not found",0,-1). This returns the value from column K of the most recent previous matching row.
To return columns K through N instead, enter =XLOOKUP(1,(D$2:D25=D26)*(F$2:F25=F26)*(G$2:G25=G26),K$2:N25,"Not found",0,-1) in P26. Make sure P26 through S26 are empty so the results can spill.
Drag the fill handle down from P26 to apply the formula to later rows. The lookup range starts at row 2 and expands to include all rows above each result.

Retrieve Previous Matching Rows in WPS Spreadsheets
Use XLOOKUP in a version of WPS Spreadsheets that supports the function to match multiple criteria and retrieve values from earlier rows.
- 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Check the criteria columns: On the worksheet, confirm that columns D, F, and G contain the values to match and that column K contains the value to return.
- 3. Enter the formula: Select an empty cell such as P26 and enter =XLOOKUP(1,(D$2:D25=D26)*(F$2:F25=F26)*(G$2:G25=G26),K$2:K25,"Not found",0,-1).
- 4. Fill down: Drag the fill handle down from P26 to search previous rows for each subsequent record.

Frequently Asked Questions
Why does XLOOKUP return the current row instead of a previous one?
A lookup range such as D:D includes the current row. Limit the lookup ranges to rows above it, such as D$2:D25 when the formula is on row 26.
How do I return multiple columns from the matching row?
Change the return array from K$2:K25 to K$2:N25 and enter the formula in a cell with three empty cells to its right. The results spill across four columns.
How can I return the nearest previous match?
Set XLOOKUP's search_mode argument to -1. This searches the specified previous-row range from bottom to top.
Why does the formula show “Not found”?
No earlier row matches all three criteria, or the values differ in ways such as extra spaces or text-versus-number formatting. Check the values in columns D, F, and G and confirm that the lookup ranges cover the intended rows.
Does XLOOKUP work in every version of Excel?
No. XLOOKUP is available in Microsoft 365 and newer standalone versions such as Excel 2021 and Excel 2024, but not in Excel 2016 or Excel 2019.




