Arrayformula does not expand past first row - google-sheets

=ArrayFormula({"test"; IF(AND(Q2:Q="true", R2:R="true"), "match", "")})
For some reason I am only getting a value in row 2. Am I missing something?

can you try either & see if it works:
=ArrayFormula({"test"; IF((Q2:Q=TRUE)*(R2:R=TRUE), "match", "")})
OR
=ArrayFormula({"test"; IF((Q2:Q="true")*(R2:R="true"), "match", "")})

As rockinfreakshow correctly stated, there are some functions that you cannot use with ARRAYFORMULA. Two of them are AND and OR, so the way you work it out is to use multiplications for conditions that are needed to be met together (AND) and sums for conditions that needed to be met one or more of them (OR)
So, picturing the TRUEs and FALSEs as 1s or 0s, if you have one condition not met in AND all the result will return 0 (110*1 = 0) and with just one condition met in OR you'll have a TRUE value (0+0+1+0= 1, 0+1+1+1 = 3, any number over 0 will be considered as TRUE).
All that said, you can express your conditions:
=ARRAYFORMULA({"test"; IF((Q2:Q=TRUE)*(R2:R=TRUE), "match", "")})
or
={"test"; ARRAYFORMULA(IF((Q2:Q=TRUE)*(R2:R=TRUE), "match", ""))}

Related

check value on 3 different cells and return true

=IFS(N15>=D15, M15="✓", O15>=2.5,"GREAT SUCCESS", TRUE,"EPIC FAIL")
I want to check multiple cells with if statement and only if all 3 are TRUE return 'success' but if even one of them FALSE I want to return 'fail'
IFS function params are cond1, result1, cond2, result2, ... Not stacking conditions and then the results.
From your explaination, you can just use normal IF, with AND like this:
=IF(AND(N15>=D15, M15="✓", O15>=2.5),"GREAT SUCCESS","EPIC FAIL")
If all 3 are correct, print "GREAT SUCCESS", else print "FAIL".
To apply to all row, instead of copy pasting or dragging the mouse to the entire table, you can use ARRAYFORMULA in the first row (don't do this if you're planning to export to xls/xlsx for Excel usage).
=ARRAYFORMULA(IF(AND($N$1:$N>=$D$1:$D, $M$1:$M="✓", $O$1:$O>=2.5),"GREAT SUCCESS","EPIC FAIL"))
Change the first row (N1, D1, M1) to your desired number, and maybe also adding the end row. (The formula above will apply to the end of sheet.)

Return TRUE if two conditions are met but one of them has two options

Google sheets issue. I want a formula that will return TRUE or FALSE if two conditions are met. However for one of the conditions there are two possibilities.
IF A2="Pizza OR Banana" AND B2="Food" then return TRUE
How can I go about it? For now I did the following but I am missing one option (banana):
=IF(AND($A2="Pizza"),$B2="Food")
Thank you!
You could use a formula like
=IF(AND(OR(A2="Pizza", A2="Banana"), B2="Food"), TRUE, FALSE)
Edit:
As pointed out by MattKing, you don't need the IF here at all since AND will give you TRUE/FALSE, you can just use:
=AND(OR(A2="Pizza", A2="Banana"), B2="Food")
try:
=((A2="Pizza")+(A2="Banana"))*(B2="Food")
What if I wanted it to not be case sensitive and to work with Food-FOOD-food and other variants?
=AND(REGEXMATCH($A$2,"(?i)^pizza$|^banana$"),REGEXMATCH($B$2,"(?i)food"))
Use REGEXMATCH instead gives you more control on the conditions.
In this example,
the first REGEXMATCH will do non-case-sensitive check on A2 to see if it is a word started with 'p' end with 'a' spell as 'pizza' or started with 'b' end with 'a' spell as 'banana' (if anything is added before or after 'pizza' and 'banana', such as 'ppizzaa', it returns false),
the second REGEXMATCH do non-case-sensitive check on B2 to see if it is any variants which includes 'food' (even something like 'xFooDy' will return true).

Return TRUE of OR operation Google Sheets

Is there any way that I can get the true value of an OR operation? Something like this?
=OR(value1, value2, value3) return value that is true
try:
=OR(value1, value2, value3)=TRUE
example:
=OR(A1=1, A1=2, A1=3)=TRUE
Taking this question's title literally, the value of any true Or function is always True. However that's probably not what OP is seeking but there's a fundamental misunderstanding that an Or function can have values. Specifically, this question makes a nonsensical assumption that an OR function can have value1, value2, value3. An Or function contains evaluations that return true or false -- no third value possible.
To illustrate, what value would be returned from this Or formula?
=Or(Not(Isnumber(A1)),len(A1)<5,left(C1,1)="G")
However, I understand that this is probably specific to some customized situation. The solution is that some other formula, functionality is needed. If you're evaluating a single cell (i.e. if cell A1 has any three values), then Erik Tyler's proposal of just using an if statement is your answer
=ArrayFormula(IF(OR(A1={5,10,15}),A1,))
(a less elegant but simplified formula that returns the same would be: =if(Or(A1=5,A1=10,A1=15),A1,)
For finding some true values in a range, there are all kinds of possibilities. However to get you started, you might consider using a filter function combined with boolean logic of (evaluation1)+(evaluation2).
See below formula will list off cell addresses of all true values in this Filter function.
=FILTER(Address(ROW(A:A),COLUMN(A:A),4),(A:A=3)+(A:A=5)+(A:A="Hello"))

Username using * in the criteria countif

i m searching sum of class of each student using countif formula, but any student have unique username like A*di (in the image) and so the calculation is false. And any other student using username like </John>, and 'Angel. and make calculation false
Formula: =COUNTIF('Data Asli'!$A:$A,$A$2)
Use SUMPRODUCT(--EXACT(..)) to run an exact, case-sensitive comparison that ignores wildcards:
=SUMPRODUCT(--EXACT('Data Asli'!$A:$A,$A2))
How it works:
EXACT(Value1, Value2) will return TRUE or FALSE, depending on whether the 2 values exactly match (same capitals, no wildcards, et cetera)
-- will convert TRUE/FALSE into 1/0
SUMPRODUCT(Array1[,Array2]) will run down the arrays, multiply the numbers together, then add them. It also forces many functions to both treat a Range as an array, and output an array.
So, as an example, the steps run like this:
=SUMPRODUCT(--EXACT(A1:A5, A2))
=SUMPRODUCT(--EXACT({Value1,Value2,Value3,Value4,Value2}, Value2))
a.k.a.
=SUMPRODUCT(--{EXACT(Value1,Value2),EXACT(Value2,Value2),EXACT(Value3,Value2),EXACT(Value4,Value2),EXACT(Value2,Value2)})
=SUMPRODUCT(--{FALSE,TRUE,FALSE,FALSE,TRUE})
=SUMPRODUCT({0,1,0,0,1})
=2

COUNTIFS with multiple ANDS and ORS

I want to count the number of rows that meet certain criteria, with both AND and OR conditions.
As long as I'm using only AND conditions, it works perfectly. Adding multiple OR conditions gives an #N/A output though.
I can't find the solution anywhere here, have been reading about applying Arrayformula and Range but not sure how to use it.
Any help is much appreciated:
=> Count the records where several AND conditions are met, and at least one of the OR conditions:
=COUNTIFS(K3:K; ">0"; S3:S; "No"; OR(M3:M < 50%; F3:F < 0,9; E3:E > 24))
Thanks!
Simplifying your requirement (ref. mcve) to counting instances where two columns are mandatory (A and B) and one at least of three others (C, D and E) is obligatory, and where the conditions are all for the presence or not of the column letter, and assuming columns are labelled (and , for delimiter) then perhaps:
=sumproduct((A2:A="a")*(B2:B="b")*(C2:C="c")+(A2:A="a")*(B2:B="b")*(C2:C<>"c")*(D2:D="d")+(A2:A="a")*(B2:B="b")*(C2:C<>"c")*(D2:D<>"d")*(E2:E="e"))
However it may be easier to flag the relevant rows, say with:
=and(K3>0;S3="No";or(M3<50%;F3<0,9;E3>24))
and then count the flags.

Resources