Bug 139649 - [1] Wrong condition behavior with cell range and sheet name
Summary: [1] Wrong condition behavior with cell range and sheet name
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.5.7.2 release
Hardware: x86-64 (AMD64) All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 141389 (view as bug list)
Depends on:
Blocks: Conditional-Formatting
  Show dependency treegraph
 
Reported: 2021-01-15 14:47 UTC by kardjoe
Modified: 2025-06-06 07:50 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
test condition (18.75 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-01-15 14:47 UTC, kardjoe
Details
Sample modified with more test (19.99 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-01-16 01:31 UTC, m_a_riosv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kardjoe 2021-01-15 14:47:02 UTC
Description:
Sometimes in Libreoffice Calc I use condition to compare range of cells in one field with respective range of cells in another field using 'Conditional' button on the toolbar. I highlight cells instead of writing a range manually. Let's say I use option 'Cell value is' in 'Conditional formatting'. I choose 'less than' option, put cursor on the right field, than I highlight cells. Range of cells with sheet name appears in the field like $'Sheet name'.$A$1:$A$10. After clicking OK sometimes compare process go wrong. For example, if A1 is 1 and B1 is 1, formatting shows that A1 is bigger than B1.



Steps to Reproduce:
1. Create a sheet.
2. Fill range A1:A10 with some numbers.
3. Copy those numbers to range B1:B10 respectively.
4. Open 'Conditional' -> 'Manage'.
5. Click 'Add'.
6. Set 'Condition 1' as 'Cell value is'.
7. Set 'less than'.
8. Put cursor on the next field and highlight with cursor range of B1:B10.
9. Click 'Shrink' button at the left bottom corner.
10. Highlight range A1:A10.
11. Click OK.

Actual Results:
Number in one cell is highlighted as not equal to a number in respective cell in another field when two these numbers are actually equal.

Expected Results:
Numbers in respective cells should not be highlighted when they are equal and one use 'less than' condition.


Reproducible: Sometimes


User Profile Reset: Yes



Additional Info:
Version: 6.4.6.2
Build ID: 1:6.4.6-0ubuntu0.20.04.1
CPU threads: 24; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: ru-RU (en_US.UTF-8); UI-Language: en-US
Calc: threaded

Not sure if it depends on if I compare a simple number and a function result or simple numbers.

Possible workaround - remove sheet name (like $'Sheet name') in 'Conditional Formatting' in the right field.

Example with a Calc sheet where I see such  behavior is attached. Look at F and G fields. I've faced this bug when I work with LO versions 6.4.6.2 and 7.0.4.2.
Comment 1 kardjoe 2021-01-15 14:47:40 UTC
Created attachment 168913 [details]
test condition
Comment 2 Roman Kuznetsov 2021-01-15 16:26:04 UTC
confirm in

Version: 7.2.0.0.alpha0+ (x64)
Build ID: 94f6765d6ecc3145fa2d266231124003cf953118
CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: CL

and in 3.5.7.2, I think it inherrited from OOo
Comment 3 m_a_riosv 2021-01-16 01:31:59 UTC
Created attachment 168927 [details]
Sample modified with more test

Seems the issue it's in relation with the use of the sheet name in the range to compare, behaving just the inverse it should be in the comparison, and comparing all with F2.

Works fine without sheet name, column K
Comment 4 Heiko Tietze 2022-07-08 07:29:06 UTC
*** Bug 141389 has been marked as a duplicate of this bug. ***
Comment 5 QA Administrators 2024-07-08 03:16:27 UTC Comment hidden (obsolete)
Comment 6 Mike Kaganski 2025-06-06 07:50:40 UTC
This is not a bug.

In attachment 168913 [details], the conditional formatting rule is exactly

> Cell value - Is less than - $'1'.$G$2:$G$13

And the range, that this conditional formatting applies to, is F2:F13.
You could imagine, that in this case the same "by intersection" rules would apply, and for each cell in the range, the respective cell in $'1'.$G$2:$G$13 will be picked. But it is not the case for conditional formatting.

When you define conditional formatting, you always work as if you are working with a single cell, which is the topmost leftmost (in LTR) cell of the range. The conditional format will be compiled for that case.

This means, that your condition converts to "apply this format, when the value is less than the *absolutely-referenced* cell obtained by intersection of F2 and $'1'.$G$2:$G$13", which is exactly one fixed cell, $'1'.$G$2. This is the value, that all the cells in the range are compared to.

You don't need to provide the G2:G13 range at all; and you definitely don't want to use absolute addressing here. What you need is a formula, that would read "compare to a cell that is same row, next column" - which, for F2 (the top left of your "apply to" range) is "Cell value - Is less than - G2". So instead of "$'1'.$G$2:$G$13", you only need "G2".

Note that this works exactly the same way in e.g. MS Excel.