I currently have the following formula in A3:
=iferror(if(A1="","",1),0)
I want to change it so that this logic remains the same but A2 should also be checked to make sure it is False. If A2 is false, the same logic of the formula above should apply when it is false.
If A2 is true, it should behave the same way as the logic above, when it is true.
I'm having trouble properly converting this :-/
I was trying it with =AND but got confused how to make sure that the same logic applies as the check above when A2 is False and True respectively.
Iferror only checks if the entire expression returns an error, not a cell by cell. To get what you want, you should modify your condition to simply check for an error in cell a1 or a2, and then write your if statement based on that. Assuming you want a 0 if either cell has an error, then this should work: =if(Or(ISERROR(A1),ISERROR(A2)),0,if(A1="","",1))
try:
=IFERROR(IF((A1="")*(A2=FALSE),, 1), 0)
which reads as: if A1 is empty and A2 equals false output empty cell otherwise output 1 and if any kind of error occurs output 0
Related
I need a way to "send" the value of one cell to another cell on a different sheet. the catch is the expression cannot be in either of those 2 cells.
i was trying something like =IF(B2<>C1,VLOOKUP(A2,'Part Data'!E:H,4)=B2)
A2 = the reference for the lookup (in this instance its a part #)
B2 = the value i want moved to the vlookup location
C1= the value currently in the vlookup location (using another vlookup to pull that value from the other sheet)
try:
=IF(B2<>C1, VLOOKUP(A2, 'Part Data'!E:H, 4, 0)=B2)
which will give you TRUE or FALSE
In Google Sheets, when using ArrayFormula with AND formula, I don't get the results as it should be.
A
B
6
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:
Why is ArrayFormula not repeated for all cells in the column?
Why do I get true without ArrayFormula and False with Arrayformula?
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)
Take this formula for instance:
=ARRAYFORMULA(IF(ISNUMBER(G3:G),IF(AND( G3:G>=7.5,G3:G<=8),"Full Day",IF(AND(G3:G>8,G3:G<24) ,"Full Day+",IF(AND(G3<7.5,G3>=4),"Half Day",IF(G3<4,"Short Leave",)))),))
Since you use the ARRAYFORMULA function you should use * instead of the AND function.
=ARRAYFORMULA(IF(ISNUMBER(A3:A),IF((A3:A>=7.5)*(A3:A<=8),"Full Day",IF((A3:A>8)*(A3:A<24) ,"Full Day+",IF((A3<7.5)*(A3>=4),"Half Day",IF(A3<4,"Short Leave",)))),))
When using the ARRAYFORMULA function you should use * instead of the AND function and + instead of the OR function.
Explanation
I don't recall an official site about this right now. In any case.
Point 1
Within an arrayformula, AND gives a single value. Not an array of TRUE/FALSE.
Point 2
You must also remember that in "math language", TRUE=1 and FALSE=0
Meaning
+----------+--------+
| Formula | Result |
+----------+--------+
| =TRUE+2 | 3 |
| =FALSE+2 | 2 |
+----------+--------+
As you can see one can interchange between boolean TRUE/FALSE and 1/0 numbers.
Point 3
About the AND function
The AND function returns true if all the provided arguments are logically true and false if any of the provided arguments are logically false.
Putting it all together
In an arrayformula, instead of using AND/OR when making comparisons, we take advantage of the above information.
So, the "multiplication" (A3:A>=7.5)*(A3:A<=8) will return 1 (meaning TRUE) only if both sides return TRUE. All other conditions return 0 (meaning FALSE).
This is the exact behaviour of the AND function and does work in an ARRAYFORMULA.
About the OR function
The OR function returns true if any of the provided arguments are logically true and false if all of the provided arguments are logically false.
The same logic is applied within the arrayformula, when using + ("addition") instead of the OR function.
AND doesn't go with an Arrayformula. However, there is an interesting way to use AND and OR operators without really using them.
While using arrayformula, in order to do an AND function you must multiply the 2 conditions, for example
=arrayformula(if((condition1)*(condition2), value if true, value if false))
Similarly using OR functions is identical EXCEPT instead of a "*" Symbol you would ADD the 2 conditions.
=arrayformula(if((condition1)+(condition2), value if true, value if false))
Why is ArrayFormula not repeated for all cells in the column?
As addressed in previous answers,
AND, ANDs the whole array, without regarding dimensions. But, given the recent updates in spreadsheets, using AND respecting dimensions, is now possible. If you want AND, by row, you can use BYROW:
=BYROW(
A2:B4,
LAMBDA(
row,
AND(INDEX(row,0,1)>5,INDEX(row,0,2)>6))
)
Here, INDEX is used to access the first column and second column of every row. If you don't want to use INDEX, Another alternative is MAP , which provides a MAP of every argument before LAMBDA:
=MAP(A2:A4, B2:B4, LAMBDA(a,b,AND(a>5,b>6)))
A
B
MAP
BYROW
6
7
TRUE
TRUE
8
1
FALSE
FALSE
9
7
TRUE
TRUE
In Google Sheets, when using ArrayFormula with AND formula, I don't get the results as it should be.
A
B
6
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:
Why is ArrayFormula not repeated for all cells in the column?
Why do I get true without ArrayFormula and False with Arrayformula?
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)
Take this formula for instance:
=ARRAYFORMULA(IF(ISNUMBER(G3:G),IF(AND( G3:G>=7.5,G3:G<=8),"Full Day",IF(AND(G3:G>8,G3:G<24) ,"Full Day+",IF(AND(G3<7.5,G3>=4),"Half Day",IF(G3<4,"Short Leave",)))),))
Since you use the ARRAYFORMULA function you should use * instead of the AND function.
=ARRAYFORMULA(IF(ISNUMBER(A3:A),IF((A3:A>=7.5)*(A3:A<=8),"Full Day",IF((A3:A>8)*(A3:A<24) ,"Full Day+",IF((A3<7.5)*(A3>=4),"Half Day",IF(A3<4,"Short Leave",)))),))
When using the ARRAYFORMULA function you should use * instead of the AND function and + instead of the OR function.
Explanation
I don't recall an official site about this right now. In any case.
Point 1
Within an arrayformula, AND gives a single value. Not an array of TRUE/FALSE.
Point 2
You must also remember that in "math language", TRUE=1 and FALSE=0
Meaning
+----------+--------+
| Formula | Result |
+----------+--------+
| =TRUE+2 | 3 |
| =FALSE+2 | 2 |
+----------+--------+
As you can see one can interchange between boolean TRUE/FALSE and 1/0 numbers.
Point 3
About the AND function
The AND function returns true if all the provided arguments are logically true and false if any of the provided arguments are logically false.
Putting it all together
In an arrayformula, instead of using AND/OR when making comparisons, we take advantage of the above information.
So, the "multiplication" (A3:A>=7.5)*(A3:A<=8) will return 1 (meaning TRUE) only if both sides return TRUE. All other conditions return 0 (meaning FALSE).
This is the exact behaviour of the AND function and does work in an ARRAYFORMULA.
About the OR function
The OR function returns true if any of the provided arguments are logically true and false if all of the provided arguments are logically false.
The same logic is applied within the arrayformula, when using + ("addition") instead of the OR function.
AND doesn't go with an Arrayformula. However, there is an interesting way to use AND and OR operators without really using them.
While using arrayformula, in order to do an AND function you must multiply the 2 conditions, for example
=arrayformula(if((condition1)*(condition2), value if true, value if false))
Similarly using OR functions is identical EXCEPT instead of a "*" Symbol you would ADD the 2 conditions.
=arrayformula(if((condition1)+(condition2), value if true, value if false))
Why is ArrayFormula not repeated for all cells in the column?
As addressed in previous answers,
AND, ANDs the whole array, without regarding dimensions. But, given the recent updates in spreadsheets, using AND respecting dimensions, is now possible. If you want AND, by row, you can use BYROW:
=BYROW(
A2:B4,
LAMBDA(
row,
AND(INDEX(row,0,1)>5,INDEX(row,0,2)>6))
)
Here, INDEX is used to access the first column and second column of every row. If you don't want to use INDEX, Another alternative is MAP , which provides a MAP of every argument before LAMBDA:
=MAP(A2:A4, B2:B4, LAMBDA(a,b,AND(a>5,b>6)))
A
B
MAP
BYROW
6
7
TRUE
TRUE
8
1
FALSE
FALSE
9
7
TRUE
TRUE
Cell A1 = "YES"
Cell B1 = "YES"
Is it possible to write a formula that makes Cell C1 EQUAL TRUE if Cell A1 MATCHES Cell B1?
It's a super simple thing I'm trying to do, but I can't find anything useful in the Google Sheets documentation. I know this is possible in MS Excel.
you can actually just put =eq(A1,B1) and the default values are true or false.
Or if you prefer a different response you can make it an if statement and choose your own text i.e.
=if(eq(A1,B1),"Yes","No")
Answered my own question:
=ArrayFormula(IF(EQ(A1, B1), TRUE, FALSE) )
I cannot have VLOOKUP to properly work if it has to match computed values.
Please see this example:
In test sheet, row 1 tests data in computed sheet, where B2 cell is the result of =RIGHT(A1, 4).
Value 1234 is not found
Meanwhile, on row 2 of test, if 1234 is the hardcoded value of the cell — sheet hardcoded —
Value is found.
Is this a bug?
Is it enough for you to change your formula to =value(RIGHT(A1,4)) ?
I'd say not a bug (Excel behaves the same way). Use of =RIGHT has automatically output as a string. If instead you had had =1233+1 you should not have had any problem.