Bug 142953 - CALC OFFSET error when used with named range of multiple cells for the reference arg and defaults
Summary: CALC OFFSET error when used with named range of multiple cells for the refere...
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-20 09:07 UTC by Simon
Modified: 2024-04-01 03:12 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
spreadsheet showing error (9.23 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-06-21 00:26 UTC, Simon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon 2021-06-20 09:07:13 UTC
Description:
Linux LibreOffice v6.4.7.2 OFFSET has an error when the 1st arg is a named range that refers to a column not a single cell.

If all args are fully specified it works as expected using the first cell referenced in the named range.

If however the length and width of the returned array are not specified (which default to 1,1), then it does not matter what is input for the row arg, the result is always the same cell value.

Obviously, the workaround is to specify all args, but unintended errors can occur if you don't know, so could this be flagged for future fix please.

Thank you from longtime grateful user of LO CALC

Steps to Reproduce:
1.create named range of multiple cells say myRange
2.create cell  =OFFSET( myRange, 1, 0)
3.vary row arg to see the same value
4. now amend OFFSET to add defaults explicitly 1,1 - do same vary row

Actual Results:
see above

Expected Results:
see above


Reproducible: Always


User Profile Reset: No



Additional Info:
see above
Comment 1 m_a_riosv 2021-06-20 12:20:48 UTC
Please can attach your sample file to test.
Comment 2 [REDACTED] 2021-06-20 15:26:53 UTC
(In reply to Simon from comment #0)
> 1.create named range of multiple cells say myRange
> 2.create cell  =OFFSET( myRange, 1, 0)

This doesn't work at all and gives a "#VALUE!" (wrong data type) error. This needs to be an array formula "{=OFFSET( myRange;1;0)}" to work, if myRange is a multicell range.
Comment 3 Simon 2021-06-21 00:26:39 UTC
Created attachment 173044 [details]
spreadsheet showing error
Comment 4 Simon 2021-06-21 00:27:18 UTC
(In reply to m.a.riosv from comment #1)
> Please can attach your sample file to test.

Done
Comment 5 Simon 2021-06-21 00:28:53 UTC
(In reply to Uwe Auer from comment #2)
> (In reply to Simon from comment #0)
> > 1.create named range of multiple cells say myRange
> > 2.create cell  =OFFSET( myRange, 1, 0)
> 
> This doesn't work at all and gives a "#VALUE!" (wrong data type) error. This
> needs to be an array formula "{=OFFSET( myRange;1;0)}" to work, if myRange
> is a multicell range.

NO !

See attachment
Comment 6 raal 2022-01-25 21:47:16 UTC
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html#__RefHeading__1018434_715980110

Tested with excel and result is the same as in Calc.
Comment 7 Roman Kuznetsov 2022-10-31 18:04:01 UTC
Simon please retest your problem in latest 7.4.2 version
Comment 8 QA Administrators 2023-04-30 03:22:48 UTC Comment hidden (obsolete)
Comment 9 ady 2023-04-30 11:12:11 UTC
Using attachment 173044 [details], still repro in 7.6.alpha built 2023-04-27.

In attachment 173044 [details], the named range upper-left cell is A3, but the OFFSET formula doesn't seem to take cell A3 as base. Instead, it just takes "one row up" as base (when the height and width arguments are not explicitly provided): for the formula in cell C7, the OFFSET() function is taking the base at cell A6 ("one row up").

In contrast, when the height and width arguments are provided, the base for OFFSET seems to be indeed cell A3 (upper-left cell of the range).
Comment 10 ady 2023-04-30 11:23:57 UTC
Using attachment 173044 [details]

=SUM(OFFSET(myRange; 1; 0; 1;1))
Result: 2 (correct)

=SUM(OFFSET(myRange; 1; 0))
Result: 152 (the enire named range except for the first upper-left value)

Also, inherited from OOo.
Comment 11 m_a_riosv 2023-05-01 06:18:05 UTC
(In reply to ady from comment #10)
> .
> =SUM(OFFSET(myRange; 1; 0))
> Result: 152 (the enire named range except for the first upper-left value)

Because in this case, OFFSET return a reference, not a single cell.
https://help.libreoffice.org/latest/en-US/text/scalc/01/04060109.html?DbPAR=CALC#bm_id3158430, see the samples.
Comment 12 ady 2023-05-01 11:41:12 UTC
(In reply to m.a.riosv from comment #11)
> (In reply to ady from comment #10)
> > .
> > =SUM(OFFSET(myRange; 1; 0))
> > Result: 152 (the enire named range except for the first upper-left value)
> 
> Because in this case, OFFSET return a reference, not a single cell.
> https://help.libreoffice.org/latest/en-US/text/scalc/01/04060109.
> html?DbPAR=CALC#bm_id3158430, see the samples.

Right. Sorry for that; I got temporarily confused by the first results, without SUM(), and by the initial assumption in comment 0:

(In reply to Simon from comment #0)
> If however the length and width of the returned array are not specified
> (which default to 1,1), then it does not matter what is input for the row
> arg, the result is always the same cell value.

That is not correct. When the height and width are not provided, the default is the same size as the original range.


The initial question still remains. In the current behavior, OFFSET(myRange;1;0) (_not_ as array formula) provides not the first value of the new range (i.e. the second value of myrange) but the value corresponding to the same row in which the formula was introduced. I guess this behavior is probably useful in some cases in order to avoid using array formulas.


I wonder what other tools do with the same formulas, _not_ using attachment 173044 [details] but rather entering them anew in a new, clean spreadsheet. (In comment 6, it is not clear to me whether raal tested by using the same file attachment 173044 [details] or by using a new empty spreadsheet, which might not provide the same result).
Comment 13 Wolfgang Jäger 2023-09-02 10:35:17 UTC
The result would be exactly the same if in place of the defined range name the explicit designator ($Sheet1.$A$3:$A$19 in the example) it stands for is used in the OFFSET() expression.

That's because the expression is correctly evaluated in intersection mode. 
See subchapter 6.3.3 "Implied intersection" of 
"Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula"

To get what the bug reporter expected (hoped for) 
=OFFSET(myRange; 1; 0; 1; 1)
entered for array evaluation would help.
[INDEX() may also help to get a workaround. I think INDEX() is not eligible for intersection mode(?).]

Suggest change to NOTABUG.
Comment 14 Wolfgang Jäger 2023-09-02 10:43:09 UTC
An actual bug shown in the example the bug reporter attached may be that the interection mode is handled as if the defined range was $Sheet1.$A$3:$A$20.
But this is also the case if $Sheet1.$A$3:$A$19 is used explicitly.
Comment 15 QA Administrators 2024-03-01 03:17:00 UTC Comment hidden (obsolete)
Comment 16 QA Administrators 2024-04-01 03:12:16 UTC
Dear Simon,

Please read this message in its entirety before proceeding.

Your bug report is being closed as INSUFFICIENTDATA due to inactivity and
a lack of information which is needed in order to accurately
reproduce and confirm the problem. We encourage you to retest
your bug against the latest release. If the issue is still
present in the latest stable release, we need the following
information (please ignore any that you've already provided):

a) Provide details of your system including your operating
   system and the latest version of LibreOffice that you have
   confirmed the bug to be present

b) Provide easy to reproduce steps – the simpler the better

c) Provide any test case(s) which will help us confirm the problem

d) Provide screenshots of the problem if you think it might help

e) Read all comments and provide any requested information

Once all of this is done, please set the bug back to UNCONFIRMED
and we will attempt to reproduce the issue. Please do not:

a) respond via email 

b) update the version field in the bug or any of the other details
   on the top section of our bug tracker

Warm Regards,
QA Team

MassPing-NeedInfo-FollowUp