Bug 154868 - Incorrect LOOKUP result when Search contains '-'
Summary: Incorrect LOOKUP result when Search contains '-'
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.6.2 release
Hardware: All All
: medium normal
Assignee: Rafael Lima
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-17 16:28 UTC by duncan.a
Modified: 2023-04-17 18:36 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Small sample file (12.02 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-04-17 16:47 UTC, Rafael Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description duncan.a 2023-04-17 16:28:49 UTC
The main table contains a list of Lookups to determine a value for a particular part.

All Cell formats have been set to TEXT

In this example, Cell B264 Contains 'TSSOP-48'
Cell C264 contains =LOOKUP(B264, Packages.$A$2:$B$208)

The Packages Table contains

Cell Ref A, B below
'TSSOP-16', 1
'TSSOP14', 17
'TSSOP20', 17
'TSSOP-48', 17

The Lookup function should return '17' but returns '1' suggesting that it's not searching for an exact text match.
Comment 1 Rafael Lima 2023-04-17 16:47:26 UTC
Created attachment 186745 [details]
Small sample file

Reproduced in

Version: 7.5.2.2 (X86_64) / LibreOffice Community
Build ID: 50(Build:2)
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 4:7.5.2~rc2-0ubuntu0.22.10.1~lo1
Calc: threaded

Adding the "-" character makes it stop working. If you remove the "-" it works.
Comment 2 Mike Kaganski 2023-04-17 17:06:10 UTC
This is not a bug.
As explained in the LOOKUP function help [1]:

> the search vector for the LOOKUP must be sorted ascending, otherwise the search
> will not return any usable results.
> 
> If LOOKUP cannot find the search criterion, it matches the largest value in the
> search vector that is less than or equal to the search criterion.



[1] https://help.libreoffice.org/latest/en-US/text/scalc/01/04060109.html?DbPAR=CALC#bm_id3159273
Comment 3 Rafael Lima 2023-04-17 18:36:50 UTC
(In reply to Mike Kaganski from comment #2)
> This is not a bug.

Thanks for the clarification.