Bug 107459 - MATCH with third parameter MatchType=-1 fails if the SearchVector is passed directly as the result of an array-formula.
Summary: MATCH with third parameter MatchType=-1 fails if the SearchVector is passed d...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2017-04-26 21:13 UTC by Wolfgang Jäger
Modified: 2020-04-30 21:33 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Demonstration announced in the original bug report (13.15 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-04-26 21:13 UTC, Wolfgang Jäger
Details
Sample file (15.25 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-04-30 14:27 UTC, m.a.riosv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2017-04-26 21:13:29 UTC
Created attachment 132876 [details]
Demonstration announced in the original bug report

{=MATCH($E3;$C$3:$C$11;-1)} e.g. is returning the correct result even if it is unnecessarily entered for array evaluation. 

{=MATCH($E3;0+$B$3:$B$11;-1)} returns the position of the wrong end if the SearchVector is containing a group of equal values determining the match.  

In the attached example this is demonstrated for the case that C3:C11 is calculated by exactly the same trivial array formula provoking the error if directly passed to MATCH. 

The bug may have sparse gray hair, and the demonstrated case is not realistic. There ARE applications of some interest, and it's a bug anyway.
Comment 1 m.a.riosv 2017-04-28 22:55:36 UTC
The issue with your second formula is the use of '0+' as array modification, with a modification different than '0', or with any other modification or a clean array works fine for me.

So it can be a trick way to get the reverse behavior.
Comment 2 Wolfgang Jäger 2017-04-29 23:22:01 UTC
(In reply to m.a.riosv from comment #1)
> The issue with your second formula is the use of '0+' as array modification,
> with a modification different than '0', or with any other modification or a
> clean array works fine for me.
> 
> So it can be a trick way to get the reverse behavior.

Who should have decided to establish that "trick way"? Where is it specified?

Of course, the "0+" is only the extreme simplification of what I had originally when I discovered the bug. There are also relevant formulas resulting in arrays to pass to MATCH in the second place. 
In fact I discovered the bug when I tried to get a REVERSE MATCH against an ascending column-array by something like 
{=MATCH(Value;INDEX($B$1:$B$10;ROW($B$10)-ROW($B$1:$B$10)+1;1);-1)}
I did not find too easily the way back to the root of the bug: making a difference between an array referenced directly and one with the identical elements calculated in the parameter position where it's used. 
The bug is from ancient days and seemingly was not reported all the time. It's a bug nonetheless. And it may e.g. throw light on a flaw in the design of the code concerned with array evaluation generally. It may also be an isolated problem with MATCH.
Comment 3 m.a.riosv 2017-04-30 14:27:20 UTC
Created attachment 132971 [details]
Sample file

N(In reply to Wolfgang Jäger from comment #2)
> (In reply to m.a.riosv from comment #1)
> > So it can be a trick way to get the reverse behavior.
> 
> Who should have decided to establish that "trick way"? Where is it specified?
I didn't say that.

I have done a new sample, where to seems the issue is the -1 for third MATCH parameter.
But it happens with a modified 'Reference|Array SearchRegion', what I am not sure it is allowed in the specification, at least explicitly.

http://docs.oasis-open.org/office/v1.2/csd06/OpenDocument-v1.2-csd06-part2.pdf
page 133.
Syntax: MATCH(Scalar Search ;Reference|Array SearchRegion [;Integer MatchType = 1 ]

Hi @Eike, @Winfried some light.
Comment 4 Wolfgang Jäger 2017-05-01 11:07:58 UTC
(In reply to m.a.riosv from comment #3)
> I have done a new sample, where to seems the issue is the -1 for third MATCH
> parameter.

Ack. See subject. However, I wouldn't see the -1 as the issue but as a condition for its incidence.

> But it happens with a modified 'Reference|Array SearchRegion', what I am not
> sure it is allowed in the specification, at least explicitly. 

What do you think is the rationale for the alternative "Reference|Array" given in the type position for the parameter SearchRange. We shouldn't get deceived by the slightly misleading name. Parameter names are arbitrary basically. However, type names used somewhere should be defined in advance. 
In fact there is an issue with  subchapter 4.10 of the document you mentioned. It reads as if "Array" is synonym with something like "Range" or "RangeReference". The implemented functions concerned accept Calculated Arrays anyway), and I assume this to be the intention of OpenDocument V1.2 part 2, too. A different interpretation would make powerless toys of some functions. 

Is there a draft for a next version of odf (recalc) concerning this?
Comment 5 m.a.riosv 2017-05-01 15:46:55 UTC
(In reply to Wolfgang Jäger from comment #4)
>..............
> 
For me, if it is not explicit, it's not explicit, and I can't interpreter as I like.
Even I think I understand your interpretation, that sounds reasonable.

> Is there a draft for a next version of odf (recalc) concerning this?
https://www.oasis-open.org/committees/document.php?document_id=51469&wg_abbrev=office-collab

In any case testing with a inner array gives what seems an erroneous result

=MATCH(5;{20;19;18;17;16;15;14;13;12;11;10;6;6;5;5;4;4;3;2;1};-1) = 14
           1  2  3  4  5  6  7  8  9 10  1 2 3 4 5 6 7 8 9 20

If I'm not wrong result should be 15 as happens with an unmodified address array.
Comment 6 QA Administrators 2018-05-02 02:32:37 UTC
** Please read this message in its entirety before responding **

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from http://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug