Bug 88979 - EDITING. The sheet portion of label ref are always absolute. Relative sheet ref not supported.
Summary: EDITING. The sheet portion of label ref are always absolute. Relative sheet r...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
Depends on:
Blocks: Sheet
  Show dependency treegraph
Reported: 2015-01-31 14:08 UTC by dwyoung
Modified: 2017-07-11 22:36 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:

Simple demonstration of bug per Description (12.99 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-01-31 14:08 UTC, dwyoung
Screenshot of dialog related to the bug as described. (71.72 KB, image/jpeg)
2015-02-01 17:54 UTC, dwyoung

Note You need to log in before you can comment on or make changes to this bug.
Description dwyoung 2015-01-31 14:08:39 UTC
Created attachment 112992 [details]
Simple demonstration of bug per Description

When a label is created, the reference is of form $sheet.$col$row. The sheet portion of the reference is an absolute reference. The form sheet.$col$row is not supported (i.e. with the sheet portion of the reference being a relative reference). Therefore if the sheet is copied (i.e. Edit > Sheet > Move/Copy), the labels on the new sheet always reference cells on the original sheet rather than on the new sheet itself.

This can be demonstrated as follows. In the attached file,  LabelRelSheetAddress.ods, do "Insert > Names > Labels >". In the dialog field for specifying the cell of the label, the reference is $Sheet1.$A$1 (wherein the sheet reference is an absolute reference). It doesn't allow changing it to Sheet1.$A$1 (wherein the sheet reference would be a relative reference). 
This is a problem when copying the sheet as follows.
1. "Edit > Sheet > Move/Copy (Copy is preselected) > -move to end position- > OK"
2. On new sheet "Sheet1_2", the reference in the formula of cell B2 to 'label1' is to cell Sheet1.$A$2, so the sheet reference in 'label1' was indeed treated as an absolute reference.

There's an additional problem that can be demonstrated with the attached file LabelRelSheetAddress.ods (before the demonstration steps above are done) as follows.
1. "Edit > Sheet > Move/Copy (Copy is preselected) > Insert before Sheet1 > OK"
2. On the new sheet "Sheet1_2", the cell B2 is evaluated to "#NAME?". The reference to 'label1' seems to be the problem even though "Insert > Names > Labels" shows that 'label1' is defined as column label $Sheet1.$A$1.
3. "Edit > Sheet > Move/Copy (Move)  > -move to end position- > OK". Now on "Sheet1_2", cell B2 is evaluated to 303. Moving the sheet shouldn't change the evaluation of references to labels.

See related Bug 88963.
Comment 1 m.a.riosv 2015-01-31 17:07:24 UTC
Hi @dwyoung, thanks for reporting.
When a label is created, the reference is of form $sheet.$col$row. 

Changing the scope from Document(Global) to Sheet, lets a non absolute sheet.
What I think is right.

So IMO not a bug. Please if you are not agree reopen it.

The rule is one bug one report.
So please report the second issue with a new report.
I have verified the problem, so I'll set up it as new.
Comment 2 dwyoung 2015-02-01 17:54:25 UTC
Created attachment 113029 [details]
Screenshot of dialog related to the bug as described.
Comment 3 dwyoung 2015-02-01 17:58:31 UTC
Comment on attachment 113029 [details]
Screenshot of dialog related to the bug as described.

Attachment LabelRelSheetAddress.jpg is screenshots of dialogs. On the left is the dialog for defining a label. I'm not finding a control in that dialog for setting scope, and that seems to be the essence of the problem. On the right is the dialog for defining a name and it has control for setting scope.
Comment 4 dwyoung 2015-02-01 18:00:39 UTC
Please see Comment 3 regarding reopening of this bug.
Comment 5 m.a.riosv 2015-02-01 18:15:22 UTC
Forgive me @dwyoung, you are right I was wrong with named ranges dialog. I'll try later.
Comment 6 m.a.riosv 2015-02-01 22:11:40 UTC
Version: Build ID: de093506bcdc5fafd9023ee680b8c60e3e0645d7

1) Reproducible no option for change sheet from absolute to relative.
But I'm not sure this is a bug, the label ranges I think are not part of sheet so they are not copied with it, like named ranges.
In the help:
"You can set label ranges that contain the same labels on different sheets. LibreOffice first searches the label ranges of the current sheet and, following a failed search, the ranges of other sheets."

2) Reproducible, saving and reopening solves the issue.

3) I think not an issue here, seems recover the point 2), but always remains calculated over Sheet1.

Please review.
Comment 7 dwyoung 2015-02-02 23:04:47 UTC
m.a.riosv, thank you for investigating.

1. Whether it's a bug or missing functionality, it would be good if labels could be referenced as relative references. Labels for identifying rows and columns (and individual cells as well), are important for building spreadsheets that are structured in a manner that makes them more understandable and maintainable. Calc supports copying sheets. When a sheet is designed for analysis of a single entity (e.g. economic output of a nation), the obvious way to analyze multiple instances of the same type of entity (i.e. to analyze a number of nations) is to copy the spreadsheet for one instance of the entity and then change the data for that second instance, but doing the same analysis of the data for each instance of the entity. In such a case, the formulas in the second instance that use column and row headings would likely desire for the labels they reference to refer to the column and row headings on their own sheet. So when the sheet copy is done, it would be good if the labels on the first sheet to be treated as relative references. Labels are better for this than names because a formula using a label is more understandable than a formula using a name since a labels that are column or row headings are conspicuous in their presence. On the other hand, the existence of names is determined by doing "Insert > Names > Manage", which is inconvenient.

2. I'm sorry I'm not understanding your comment. It seems like your comment says that it's acceptable for the state of a sheet to be changed by the process of saving and then opening the file - and I would be surprised for someone to say that. Can you explain more explicitly?

3. It's a bug for the state of the file to be changed by doing a file save followed by a file open. Also, it's clear to me that absolute and relative references should be supported for labels the same as they are for names.

Thank you for your consideration.
Comment 8 m.a.riosv 2015-02-02 23:40:36 UTC
1) I think perhaps it's not so easy to implement, but who knows, report a new bug and set the status as enhancement.

2) Sorry if I have not explain well, only that saving and reopening helps but of course the bug is there.

Changed status to new for:
2. On the new sheet "Sheet1_2", the cell B2 is evaluated to "#NAME?". The reference to 'label1' seems to be the problem even though "Insert > Names > Labels" shows that 'label1' is defined as column label $Sheet1.$A$1.
Comment 9 Matthew Francis 2015-04-11 15:54:29 UTC
The first part of this is an enhancement - although as already mentioned probably not a very likely one to be dealt with.

The second part was dealt with on bug 89019. If you enable:

Tools - Options - LibreOffice Calc - Calculate - General Calculations - Automatically find column and row labels

the label reference will work after copying the sheet.

So for what's left, setting:

Severity -> enhancement
Comment 10 Eike Rathke 2017-04-19 16:07:05 UTC
Labels with relative sheet references don't make much sense. As soon as rows or columns are deleted in a sheet where an affected label range is used in a formula on another sheet that formula is out of sync. Similar for insertions. What might be possible instead could be to copy labels when a sheet is copied, along with adapting all formulas on the copied sheet that use such a copied label range.

Btw, "Automatically find column and row labels" should be used with care and generally is not advisable.