Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayFormula and "AND" Formula in Google Sheets

In Google Sheets, when using ArrayFormula with AND formula, I don't get the results as it should be.

A|B 2|7 

In C1 I put formula as: =and(A1>5,B1>6) then I get True. If in D1 I put formula as: =ArrayFormula(and(A1:A>5,B1:B>6)) I get the results as False.

Here are my two questions:

  1. Why is ArrayFormula not repeated for all cells in the column?
  2. Why do I get true without ArrayFormula and False with Arrayformula?
like image 294
Hossein Avatar asked Apr 30 '17 20:04

Hossein


People also ask

Is there an AND operator in Google Sheets?

There are three basic logical operators: the NOT, the OR, and the AND operator. Google Sheets implement them as NOT(), OR(), and AND() functions, respectively. The NOT() function functions like the NOT logical operator: it flips the value from TRUE to FALSE or from FALSE to TRUE.

Can you use and with IFS in Google Sheets?

IF is a Google Sheets function that acts based on a given condition. You provide a boolean and tell what to do based on whether it's TRUE or FALSE. You can combine IF with other logical functions – AND, OR – to create nested formulas and go over multiple sets of criteria.

Can you use and in array formula?

You can't use the AND and OR functions in array formulas directly because those functions return a single result, either TRUE or FALSE, and array functions require arrays of results. You can work around the problem by using the logic shown in the previous formula.

How do I use VLOOKUP with Arrayformula in Google Sheets?

In Google Sheets, you can combine VLOOKUP with other functions to do some neat things. For example, combining VLOOKUP with ARRAYFORMULA can be used to lookup multiple pieces of data at once, which will save you steps so you don't have to enter multiple formulas.


1 Answers

AND doesn't work that way with Array formulae because it ANDs the whole array together in the top left cell, regardless of number of dimensions.

I.e. it checks if "">"" which is FALSE, ANDed with anything it will return FALSE for the top left cell, that result is carried down.

You can use multiplication of truth values to create ANDing that works with ARRAYFORMULA like this:

=ArrayFormula((A1:A>1)*(B1:B>6) = 1) 

The OR equivalent would obviously be

=ArrayFormula((A1:A>1)+(B1:B>6) > 0) 
like image 144
Robin Gertenbach Avatar answered Oct 12 '22 03:10

Robin Gertenbach