Bug 126519 - UI - Calculation incorrect with VLOOKUP function, will not correct on recalculate
Summary: UI - Calculation incorrect with VLOOKUP function, will not correct on recalcu...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.1.5.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-24 07:43 UTC by alex
Modified: 2019-07-25 11:27 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Copy of sample problem spreadsheet, with unnecessary extra data removed (17.41 KB, application/octet-stream)
2019-07-25 02:35 UTC, alex
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alex 2019-07-24 07:43:48 UTC
Description:
Some cells with an VLOOKUP formulas fail to calculate or recalculate correctly, despite formula being identical to cells above and below.
Issue survives recalculation and save/reopen of file. 
Can ultimately be resolved by copying or re-entering exactly the same formula or changing value in a precedent cell, but it seems unacceptable that it otherwise remains incorrect.

Steps to Reproduce:
Note on reproducibility - it is 100% reproducable with specific cells in a particular sample file, but I haven't attempted to arbitrarily create the issue in a new file
1.  Cells have existing, correct VLOOKUP formula, and display incorrect result
2.  Other cells in column with same formula (and same value, but differently located precedent cells) display correctly

Actual Results:
Reopen or recalculate retains incorrect value.
Whereas editing and reverting the formula, or changing precedent cell calculate correctly, so result cannot be relied on

Expected Results:
Would expect cells with same formula to always return same result


Reproducible: Sometimes


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
-openSUSE Version: 6.1.5.2 Build ID: 10(Build:2), and 
-Windows Version: 6.2.4.2 (x64) Build ID: 2412653d852ce75f65fbfa83fb7e7b669a126d6

Re userprofile: it is occurring for 2 users on 3 installations.

Further details:

Background
    1. The spreadsheet is a household budget in ODS format, where we import or enter transactions
    2. Presently 9500+ rows, but performance seems fine (and we periodically paste values only on old rows to lessen formula load).
    3. We assign categories to transactions (eg insurance, grocery) in column C
    4. In column J, we have a vlookup function against a named range to provide a group for the categories (eg Income, Expenses, Transfers)
The formula is =VLOOKUP($C9503,CatGroups,2,0)
    5. For the past 4 years this has performed exactly as expected


Description of current Problem
In recent weeks, some of the cells in with the VLOOKUP formula in colum J fail to calculate.
In an area where it occurs:
    • all cells in column C contain the same value
    • some cells in column J has calculated correctly from the VLOOKUP, returning "EXPENSES"
    • other cells in column J are displaying 0.00, which is incorrect

In testing I have established:
    1. Cell formula contents are identical apart from the relative address of eg $C9503, which alters by row only
    2. Setting calculation to manual or automatic does not fix
    3. Forced manual recalculation does not fix
    4. Saving and reopening does not fix
    5. Opening the file in openSUSE or Windows instances, and by different users produces the same error
    6. Copying an existing correctly-calculating cell from Column J DOES FIX newly pasted cells only, as does filling down with a drag handle.
    7. Manually changing the formula in the cell to something else (eg change index from 2 to 1), and then reverting DOES FIX.
    8. Performing an edit on the precedent cell eg $C9503 DOES FIX.
This works even if the value is unchanged, eg F2 to edit, add a trailing space then delete it, and press ENTER to save the unchanged value "grocery"

Comments
While the impacted cells can be found and fixed, it is not easy an easy problem to diagnose, and users should be able to trust formulas to calculate correctly!
Comment 1 m_a_riosv 2019-07-24 15:41:29 UTC
Please attach a sample file showing the issues.
Comment 2 alex 2019-07-25 02:35:28 UTC
Created attachment 152972 [details]
Copy of sample problem spreadsheet, with unnecessary extra data removed

    • the yellow highlighted cells in column C contain the same value
    • the green hightlighted cell in column J has calculated correctly from the VLOOKUP
    • the red highlighted cells in column J are displaying 0.00, which is incorrect
Comment 3 m_a_riosv 2019-07-25 06:18:08 UTC
Doing a hard recalc [Ctrl+Shift+F9] (Menu/Data/Calculate/Recalculating hard) the file works for me, after saving and reopening the file seems to works fine also.
Comment 4 alex 2019-07-25 06:28:47 UTC
(In reply to m.a.riosv from comment #3)
> Doing a hard recalc [Ctrl+Shift+F9] (Menu/Data/Calculate/Recalculating hard)
> the file works for me, after saving and reopening the file seems to works
> fine also.

Thanks for that - I can confirm that works here too.
I'd suggest that needing to do hard recalc, which as a long-time user I was not aware of, is unexpected behaviour.
I raised the bug because my wife, who is a skilled user, was unable to establish what was wrong.  
I think a normal user would expect autocalc to ALWAYS work, and a manual recalc likewise.
Interestingly my windows install menu of Menu/Data/Calculate/ contains only Recalculate, Formula to Value, and AutoCalculate - no option for the hard recalc.

I always like to learn something new, so I'll teach my wife [Ctrl+Shift+F9] too, but I'd prefer it to be more discoverable.

Thanks again for your help!
Comment 5 m_a_riosv 2019-07-25 11:27:00 UTC
If I'm not wrong Hard recald was added to the menu with 6.0 version.

There was some issues about recalculations in some circumstances, solved now.

So please update to a newer version, and if you can reproduce the issue after a hard recalc please reopen the bug