Attached is a test spreadsheet that shows the issue.
XMATCH fails when doing a numeric lookup when the lookup value is an exact match when the XMATCH match_mode is either ‘Exact match or next largest item’ or ‘Exact match or next smallest item’ AND the search_mode is search_mode ‘last to first’.
I’ve seen the issue with all versions that I tried: 24.6 and 24.10.
Note that there is a workaround by updating the XMATCH to use ‘last to first’ since ‘first to last’ vs ‘last to first’ doesn’t matter in this case in terms of results, but we are not the authors of the spreadsheet where we are seeing this issue.
val worksheet = workbook.worksheets["Sheet1"]
listOf(
"XMATCH with match_mode 'Exact match or next largest item' and search_mode 'last to first' fails, should return 6",
worksheet.calculateFormula("=XMATCH(34500, E13:E18, 1,-1)"),
"XMATCH with match_mode 'Exact match or next largest item' and search_mode 'last to first' and non-exact input succeeds, returns 6",
worksheet.calculateFormula("=XMATCH(34499, E13:E18, 1,-1)"),
"XMATCH with match_mode 'Exact match or next largest item' and search_mode 'first to last' succeeds, returns 6",
worksheet.calculateFormula("=XMATCH(34500, E13:E18, 1,1)"),
"XMATCH with match_mode 'Exact match or next smallest item' and search_mode 'last to first' fails, should return 6",
worksheet.calculateFormula("=XMATCH(34500, E13:E18, -1,-1)"),
"XMATCH with match_mode 'Exact match or next smallest item' and search_mode 'first to last' succeeds, returns 6",
worksheet.calculateFormula("=XMATCH(34500, E13:E18, -1,1)"),
"XMATCH with match_mode 'Exact match' and search_mode 'last to first' succeeds, returns 6",
worksheet.calculateFormula("=XMATCH(34500, E13:E18, 0,-1)"),
"XMATCH with match_mode 'Exact match' and search_mode 'first to last' succeeds, returns 6",
worksheet.calculateFormula("=XMATCH(34500, E13:E18, 0,1)"),
).forEach { println(it) }
The above produces the output:
XMATCH with match_mode 'Exact match or next largest item' and search_mode 'last to first' fails, should return 6
5.0
XMATCH with match_mode 'Exact match or next largest item' and search_mode 'last to first' and non-exact input succeeds, returns 6
6.0
XMATCH with match_mode 'Exact match or next largest item' and search_mode 'first to last' succeeds, returns 6
6.0
XMATCH with match_mode 'Exact match or next smallest item' and search_mode 'last to first' fails, should return 6
5.0
XMATCH with match_mode 'Exact match or next smallest item' and search_mode 'first to last' succeeds, returns 6
6.0
XMATCH with match_mode 'Exact match' and search_mode 'last to first' succeeds, returns 6
6.0
XMATCH with match_mode 'Exact match' and search_mode 'first to last' succeeds, returns 6
6.0
ExampleWorkbook.xlsx.zip (8.0 KB)