Bug Hunting Session
Bug 119137 - MAXIFS, MINIFS, SUMIFS, AVERAGEIFS: error in parameters list (Err:504) for scalar value (non-reference, non-array) as main range
Summary: MAXIFS, MINIFS, SUMIFS, AVERAGEIFS: error in parameters list (Err:504) for sc...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:6.2.0 target:6.1.1
Keywords:
Depends on:
Blocks: Cell-Formula
  Show dependency treegraph
 
Reported: 2018-08-07 08:15 UTC by Mike Kaganski
Modified: 2018-08-23 10:27 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2018-08-07 08:15:09 UTC
1. Create a new spreadsheet.
2. In A1, enter a number (e.g., 3)
3. In B1, enter formula `=MAXIFS(ROW($A$1:$A1);$A$1:$A1;3)`

Expected: B1 should give `3`.
Actual: it returns `Err:504` ("Error in parameters list").

Note that function wizard for B2 shows that first two parameters to MAXIFS return arrays ({3}), not scalars.

When B1 is drag-copied downwards, i.e., the formula starts referencing more than a single row, it starts working correctly.

Tested with Version: 6.1.0.3 (x64)
Build ID: efb621ed25068d70781dc026f7e9c5187a4decd1
CPU threads: 12; OS: Windows 10.0; UI render: GL; 
Locale: ru-RU (ru_RU); Calc: CL
Comment 1 Jacques Guilleron 2018-08-07 22:00:10 UTC
Hi Mike,

That works when I write the formula this way:
=MAXIFS($A$1:$A1;$A$1:$A1;3)
Isn't it correct?
Comment 2 Mike Kaganski 2018-08-08 04:21:43 UTC
(In reply to Jacques Guilleron from comment #1)
> That works when I write the formula this way:
> =MAXIFS($A$1:$A1;$A$1:$A1;3)
> Isn't it correct?

Well, probably then my description is incorrect, and in reality the problem is that ROW() returns a scalar when used as argument for MAXIFS() with a single-element array? Still a problem all the same ;-)
Comment 3 Xisco Faulí 2018-08-08 07:34:54 UTC
Also reproduced in

Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

@Eike, @Winfried, I thought you could be interested in this issue...
Comment 4 Eike Rathke 2018-08-20 10:16:02 UTC
Taking.
Comment 5 Eike Rathke 2018-08-20 10:28:39 UTC
Effectively MAXIFS(ROW($A$1:$A1);$A$1:$A1;3) is the same as MAXIFS(1;$A$1:$A1;3) where the first argument 1 (result of ROW($A$1:$A1)) is neither a range nor an array but a scalar value, which ScInterpreter::IterateParametersIfs() treats as error. That changes for ROW($A$1:$A2) which returns an array {1,2}

In this case a scalar value should probably be treated the same as an array of 1x1 elements.
Comment 6 Eike Rathke 2018-08-20 10:48:57 UTC
Btw, the expected result is 1 for that formula, not 3.
Comment 7 Commit Notification 2018-08-20 14:14:41 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7d785183dda20942459616110bab041f9293a399

Resolves: tdf#119137 treat scalar non-reference non-array argument as matrix

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Eike Rathke 2018-08-20 14:15:33 UTC
Pending review https://gerrit.libreoffice.org/59329 for 6-1
Comment 9 Commit Notification 2018-08-22 07:22:33 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=886b39fbd4f2401922b1c5af0a06ad09efb59d93&h=libreoffice-6-1

Resolves: tdf#119137 treat scalar non-reference non-array argument as matrix

It will be available in 6.1.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2018-08-23 10:27:04 UTC
Zdeněk Crhonek committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e854848cc7b3ca484cb749ad2f92b203764e8b18

add test for tdf#119137

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.