Bug 123401 - FILEOPEN DOCX AVERAGE table formula is not working in LO
Summary: FILEOPEN DOCX AVERAGE table formula is not working in LO
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4 all versions
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0
Keywords:
Depends on:
Blocks: Regressions-expression-is-faulty
  Show dependency treegraph
 
Reported: 2019-02-12 11:12 UTC by Xisco Faulí
Modified: 2020-08-31 11:53 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Simplier Average formula (19.31 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-02-12 11:12 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2019-02-12 11:12:11 UTC
Created attachment 149221 [details]
Simplier Average formula

Description:
AVERAGE table formula has Expression is faulty when opened in LO.

Steps to Reproduce:
    1. Create a new docx in Word.
    2. Insert a Table.
    3. Insert AVERAGE() formula to some of the cells.
    4. Save and open it in LO.

Actual Results:
The cells which had and AVERAGE formula now have ** Expression is faulty ** instead of what was in them in Word.

Expected Results:
All the cells should have the same data in them.


Reproducible: Always


User Profile Reset: No



Additional Info:
LibreOffice details: Version: 6.3.0.0.alpha0+
Build ID: 17dd2662ccfa9d04efbea74e5d7548db5b2126d4
CPU threads: 4; OS: Windows 6.1; UI render: default; VCL: win; 
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: threaded
Comment 1 Michael Warner 2020-07-12 23:42:50 UTC
I can think of two possible solutions to this, one is to add an AVERAGE function that is a synonym for MEAN; the other is to just replace calls to AVERAGE with calls to MEAN on import. Are there any strong opinions on which way to go?
Comment 2 Regina Henschel 2020-07-13 13:37:13 UTC
I would prefer to convert the function during import/export. Writer has its own proprietary formula syntax. In the long run I wish we could switch to the Open Formula syntax used in Calc. Introducing new functions in Writer would not be a step in that direction.
Comment 3 Michael Warner 2020-07-13 14:56:54 UTC
(In reply to Regina Henschel from comment #2)
> I would prefer to convert the function during import/export. Writer has its
> own proprietary formula syntax. In the long run I wish we could switch to
> the Open Formula syntax used in Calc. 

I agree with you on the long-term goal of making Writer syntax match that of Calc. To take it a step further I think that long-term, Writer table formulas should probably be calculated with the same code as used in Calc. It seems redundant to me for each application to have its own code (and incompatible syntax) for this. 

> Introducing new functions in Writer would not be a step in that direction.

Can you explain more of this perspective? AVERAGE, SIGN[1], and ABS[2] are all functions in Calc, so adding them as functions in Writer would seem like it is a step in that direction, to me. 

[1] https://bugs.documentfoundation.org/show_bug.cgi?id=123390
[2] https://bugs.documentfoundation.org/show_bug.cgi?id=123354
Comment 4 László Németh 2020-08-25 16:13:05 UTC
I have added AVERAGE to Writer formula parser as an alternative name of MEAN:

https://gerrit.libreoffice.org/c/core/+/101336

In DOCX export, also added MEAN->AVERAGE conversion.

I don't want to replace MEAN with AVERAGE on the UI, because that could break back-compatibility more often, than needed. The plan is only an interoperability extension of Writer's original formula language. I'm going to add ABS, SIGN, COUNT, too. 

It's possible to implement OpenFormula (text:formula), as an alternative future table formula language of Writer using Calc by UNO XFormulaParser, XFunctionAccess or with a hidden spreadsheet document, but OpenFormula is not the only formula language used by Calc, according to back-compatibility and interoperability issues, see

https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1sheet_1_1FormulaLanguage.html
Comment 5 Commit Notification 2020-08-26 07:57:09 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c31b436c86c0d4d287725708732c14357ed5583a

tdf#123401 DOCX: fix table formula AVERAGE

It will be available in 7.1.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 6 Xisco Faulí 2020-08-31 11:53:02 UTC
Verified in

Version: 7.1.0.0.alpha0+
Build ID: e2f4e65a7b8024c00b049eebf0d87637efda7f24
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

@László Németh, thanks for fixing this issue!!