Bug 155843 - LOOKUP function not working properly
Summary: LOOKUP function not working properly
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.7.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-14 23:31 UTC by Liam M
Modified: 2023-06-15 19:03 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
This bug is apparent on Row 2 of this spreadsheet. (30.34 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-06-14 23:31 UTC, Liam M
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Liam M 2023-06-14 23:31:29 UTC
Created attachment 187918 [details]
This bug is apparent on Row 2 of this spreadsheet.

The LOOKUP function is not doing what it's supposed to, despite being used exactly as described in the Help section. The search vector & result vector are both one column.

But I cannot figure out exactly how it determines the output. For the first many columns of cells I use as the search criterion, the function outputs "#N/A". I confirmed that the spellings do indeed match. But when I use a search criterion value that matches the first cell in the search vector column, I get the correct value. But then using any cells to the right of this one as input gives me the same output; the value of the first cell in the result vector.

I don't know what it's doing, but it's not what it's supposed to do.

I included the file as an attachment. See cells on the second row where this function is being used. It's supposed to return the 3-letter country code of the cell above.
Comment 1 m_a_riosv 2023-06-14 23:53:01 UTC
The function works fine, you need to read carefully the help, because the searched range must be sorted ascending. And column A is not sorted.
file:///C:/Program%20Files/LibreOffice/help/en-US/text/scalc/01/04060109.html?DbPAR=CALC#bm_id3159273
Comment 2 Liam M 2023-06-15 00:01:06 UTC
(In reply to m.a.riosv from comment #1)
> The function works fine, you need to read carefully the help, because the
> searched range must be sorted ascending. And column A is not sorted.
> file:///C:/Program%20Files/LibreOffice/help/en-US/text/scalc/01/04060109.
> html?DbPAR=CALC#bm_id3159273

Oh no! It does indeed say that. That's unfortunate. This really needs to be changed. Libreoffice Calc should definitely have a function that does this.
Comment 3 Werner Tietz 2023-06-15 19:03:08 UTC
(In reply to Liam M from comment #2)
…
> 
> Oh no! It does indeed say that. That's unfortunate. This really needs to be
> changed. Libreoffice Calc should definitely have a function that does this.

the Formula exists:
=VLOOKUP(D$1;$A$3:$B$28;2;0)