Bug 159425 - Formula =AND(ISBLANK(range)) with a range does not produce expected result by pressing Enter
Summary: Formula =AND(ISBLANK(range)) with a range does not produce expected result by...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.6.4.1 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-29 10:56 UTC by Bernhard G
Modified: 2024-01-29 23:16 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
sample Excel365 file with formula =AND(ISEMPTY(range)) (10.06 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2024-01-29 18:29 UTC, Bernhard G
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard G 2024-01-29 10:56:44 UTC
To check a cell range for blank cells, 

 =AND(ISBLANK(C5:M5))
 =OR(ISBLANK(C5:M5))

should return if all (or any) of the cells are blank. On Excel, this works.
But in LibreOffice the above formulae always return FALSE.  :-(   To put clearly, they do not return errors, but return a wrong result.

I am aware we can work around the issue with formulae like 

 =COUNTBLANK(C5:M5)=COLUMNS(C5:M5)
 =SUMPRODUCT(C5:M5)=COLUMNS(C5:M5)

but this makes formulae unneccessarily long, hard to read, error-prone on edits, and less elegant.

I experienced this on the current release (see below) but the issue probably exists for a long time, if not for every release.

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 8; OS: Linux 6.7; UI render: default; VCL: kf5 (cairo+xcb)
Locale: de-DE (de_DE.UTF-8); UI: de-DE
7.6.4-2
Calc: threaded
Comment 1 Mike Kaganski 2024-01-29 11:20:29 UTC
(In reply to Bernhard G from comment #0)
> On Excel, this works.

Can't see that in Excel 2016. Could you please attach a sample XLSX file, where this works with Excel?
Comment 2 Bernhard G 2024-01-29 18:29:26 UTC
Created attachment 192239 [details]
sample Excel365 file with formula =AND(ISEMPTY(range))

Initially I found this formula suggested on an Excel knowledge page (in German language):
  https://statorials.org/de/excel-ist-ein-leerer-bereich/

I made attached example XLSX file on a friend's Excel365 on Mac, also earlier today I successfully used same formula on another friend's Excel365 on Win. I cannot tell which version of Excel introduced this feature as I no longer use Excel myself, and currently have no older versions of Excel around.

BTW,
just spotting a minor error: the workarounds above should have been:

   =COUNTBLANK(C5:M5)=COLUMNS(C5:M5)
   =SUMPRODUCT(ISBLANK(C5:M5))=COLUMNS(C5:M5)

which are equivalent, or respectively

   =COUNTBLANK(C5:M5)>0
   =SUMPRODUCT(ISBLANK(C5:M5))>0

for the OR variant.
Comment 3 LeroyG 2024-01-29 18:42:27 UTC
(In reply to Bernhard G from comment #0)
>  =AND(ISBLANK(C5:M5))
>  =OR(ISBLANK(C5:M5))
> 
> should return if all (or any) of the cells are blank. On Excel, this works.
> But in LibreOffice the above formulae always return FALSE.

But if result is TRUE when at least once cell is blank, how can I know when all cells are blank?

Try with =COUNTIF($C5:$M5;"")>0

Not a bug for me.
Comment 4 Rafael Lima 2024-01-29 20:00:55 UTC
This actually works in Calc. But for you to apply the formula as an array formula you must press Ctrl+Shitf+Enter.

So basically do the following:
1) Enter the formula =AND(ISBLANK(C5:M5)) in cell A1
2) Instead of pressing Enter, press Ctrl+Shift+Enter

You'll know you did it right because the formula bar will show {AND(ISBLANK(C5:M5))} to indicate this is an array formula.

The reason for this ticket is that now Excel automatically understands that this is an array formula. Maybe LO should do the same.
Comment 5 Bernhard G 2024-01-29 22:20:49 UTC
(In reply to LeroyG from comment #3)
> (In reply to Bernhard G from comment #0)
> >  =AND(ISBLANK(C5:M5))
> >  =OR(ISBLANK(C5:M5))
> > 
> > should return if all (or any) of the cells are blank. On Excel, this works.
> > But in LibreOffice the above formulae always return FALSE.
> 
> But if result is TRUE when at least once cell is blank, how can I know when
> all cells are blank?

The AND and OR variants are not equivalent.
First variant is to check if ALL cells in range are blank.
Second variant is to check if ANY cell in range is blank.

> Try with =COUNTIF($C5:$M5;"")>0

... for the OR variant, and 
  =COUNTIF($C5:$M5;"")=COLUMNS($C5:$M5)     for the AND variant.
I agree there are workarounds, I even listed some myself. This is not the point.

> Not a bug for me.

Looking at Rafael Lima's insight in #c4 above, I am no longer sure this is an error in strict technical sense. But I still believe it is really badly designed logic, and horrible UX, to deliver a constant FALSE whenever an array formula was entered with regular [Enter] key instead of [Shift]-[Ctrl]-[Enter] (which can easily happen on a busy day). Particularly as the cursor moves away from the affected cell with both plain [Enter] and [Shift]-[Ctrl]-[Enter], so the effect is not immediately visible unless the cell is manually focused again.

Also, this only takes effect after the cell contents was factually changed (at least e.g. by adding a character and removing it). Just entering a cell by [F2] and confirming with [Shift]-[Ctrl]-[Enter] will NOT change its status from regular formula to array formula. So, it affords a clumsy procedure to change a formula from regular to array.

I might accept this if there was a valuable use of the regular formula. But does it make any sense for the regular (non-array) formula
  =AND(ISBLANK(range))
to produce a constant FALSE irrespective of the range's contents?  Is there any context where this would be helpful/useful in any way?
Comment 6 Rafael Lima 2024-01-29 22:45:05 UTC
Updated the title for better clarity.
Comment 7 Bernhard G 2024-01-29 23:05:20 UTC
(In reply to Rafael Lima from comment #4)
> This actually works in Calc. But for you to apply the formula as an array
> formula you must press Ctrl+Shitf+Enter.

Oh, right - good catch!

> You'll know you did it right because the formula bar will show
> {AND(ISBLANK(C5:M5))} to indicate this is an array formula.

That's right. Though, I may add, the braces around the formula are easily overseen.

> The reason for this ticket is that now Excel automatically understands that
> this is an array formula.

Interestingly, I am not sure how precisely E365 handles such a formula:
The example XLSX spreadsheet above, opened in LibreOffice 7.6.4.1, does show the formula with braces, so indeed it seems that E365 did automatically convert it. However IIRC, opened again in E365, the formula was again presented as a regular formula without braces. Does this mean that E365 converts it back and forth, array from/to regular, whenever the user edits the formula cell? (I may have to get back to E365 to confirm.)

This may make sense, if it causes less confusion to the user to see his formula exactly as entered. But the user may have an even harder time understanding the difference between both formula types. Maybe he no longer needs to?  

> Maybe LO should do the same.

I myself do not know enough about array formula. If it is primarily a technical distinction, and not a feature to the user, then yes, I would welcome LO to take one more burden off the user's shoulder, and do the same.
Comment 8 ady 2024-01-29 23:16:33 UTC
(In reply to Rafael Lima from comment #4)
> The reason for this ticket is that now Excel automatically understands that
> this is an array formula. Maybe LO should do the same.

Not exactly the same as the old "array formula" but rather "dynamic array", supported in MSO 365 and 2021. Older versions are "pre-dynamic array era" and do not support them, so the keyboard combination "CSE" is needed in those older versions, the same as in LO Calc.