Bug 157948 - Offset function using negative numbers for height or width works in Microsoft Excel, not in Calc
Summary: Offset function using negative numbers for height or width works in Microsoft...
Status: RESOLVED NOTOURBUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.6.2.1 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/calc-of...
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2023-10-27 15:26 UTC by Leo
Modified: 2023-11-11 07:31 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Test using negative value (9.10 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2023-10-27 19:17 UTC, Leo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leo 2023-10-27 15:26:49 UTC
Description:
In offset func:
 Height is a positive integer value, or a reference to a cell containing such a value, that specifies the total number of rows required in the modified reference. If omitted, a default value of 1 is applied.

Width is a positive integer value, or a reference to a cell containing such a value, that specifies the total number of columns required in the modified reference. If omitted, a default value of 1 is applied.

 
in excel width and height can be negative. 

integrating the possibility of using negative values ​​for height and width would allow calculations to be made using cells above the reference value (example: sum).

Actual Results:
now is not possibile use negative value

Expected Results:
now is not possibile use negative value


Reproducible: Always


User Profile Reset: No

Additional Info:
My bug is a request for a new feature.
Comment 1 Eike Rathke 2023-10-27 16:43:34 UTC
Makes no sense to me. If negative width or height shifts the offset again, then why not give the offset correctly instead? Note also that the ODF OpenFormula (ODFF) standard specification explicitly states positive integer constraints, see https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#OFFSET so it may just be an Excel quirk.

Can you attach a sample document that in Excel produces a meaningful result using negative with or height that could not be accomplished using adjusted RowOffset or ColumnOffset values?
Comment 2 Leo 2023-10-27 19:17:04 UTC
Created attachment 190458 [details]
Test using negative value
Comment 3 Eike Rathke 2023-11-01 19:05:40 UTC
So what's the difference to

B1: =SUM(OFFSET(A1;$E$1+1;0;-$E$1;1))
B2: =SUM(OFFSET(A2;$E$1+1;0;-$E$1;1))
...
B8: =SUM(OFFSET(A8;$E$1+1;0;-$E$1;1))
B9: =SUM(OFFSET(A9;$E$1+1;0;-$E$1;1))
...

? Which IMHO makes it even clearer that an actual range is shifted.
(except that Excel apparently displays #REF! error in B1:B6 instead of Err:502).
In real one probably would enter 7 in E1 and instead use
B1: =SUM(OFFSET(A1;-($E$1-1);0;$E$1;1))
...
Comment 4 Stéphane Guillou (stragu) 2023-11-11 07:30:28 UTC Comment hidden (obsolete)
Comment 5 Stéphane Guillou (stragu) 2023-11-11 07:31:14 UTC
The issue was brought up before on Ask.LO, where Eike already commented on it[1].
He explained there that MS Excel allows negative values even though both the MS documentation[2] and the OOXML specification[3] say it is not allowed.

Closing as "not our bug" (see even MS Office users reporting it[4]), but it would be good to have it mentioned in our documentation.[5]

[1]: https://ask.libreoffice.org/t/calc-offset-function-works-may-give-different-result-than-excel-equivalent/24859/5?u=stragu
[2]: https://support.microsoft.com/en-us/office/offset-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66
[3]: ECMA-376-1:2016 section 18.17.7.245, see https://ecma-international.org/publications-and-standards/standards/ecma-376/
[4]: https://answers.microsoft.com/en-us/msoffice/forum/all/offset-bug-negative-height-argument/dc24aca4-b77c-e011-9b4b-68b599b31bf5
[5]: https://wiki.documentfoundation.org/Documentation/Calc_Functions/OFFSET