ArrayFormula from several IF statements [duplicate] - google-sheets

This question already has answers here:
ArrayFormula and "AND" Formula in Google Sheets
(4 answers)
Closed 4 months ago.
I have a IF statement with several AND conditions working great for my needs, however i want/need to transform it into an ARRAYFORMULA but i just cannot get it to work...
Working formula is this
=if(AM3="";"";
if(and(COUNTIF(AM3;"*"&X3&"*");J3<>"x");"Arrival";
if(and(J3="x";L3<>"x";if(COUNTIF(AM3;"*"&X3&"*");false;true));"Departure";"")))
NOT working ARRAYFORMULA is this:
=arrayformula(if(AM2:AM="";"";
if(and(J2:J<>"x";COUNTIF(AM2:AM;"*"&X2:X&"*")>0);"Arrival";
if(AND(J2:J="x";L2:L<>"x";if(COUNTIF(AM2:AM;"*"&X2:X&"*")>0;FALSE;TRUE));"Departure";"d"))))
Can someone help and explain me why it doesn't work pls?
Thanks.

AND is not supported under AF. try:
=INDEX(IF(AL3:AL="";;
IF(REGEXMATCH(LOWER(AL3:AL); LOWER(X3:X))*(J3:J<>"x"); "Send Arrival";
IF((J3:J="x")*(L3:L<>"x")*(IF(REGEXMATCH(LOWER(AL3:AL); LOWER(X3:X));
FALSE; TRUE)); "Send Departure"; ))))

Related

VLOOKUP first 5 characters [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 months ago.
Improve this question
I know there have been many questions regarding this and I did read through these (+ the answers). But the formula suggested in each of them does not seem to work for me.
I have created a sheet for other people to look at, so that you all understand what I have been trying to do. I basically want my VLookup to search for the first 5 characters, but it's giving me an error. I used the formula that was suggested here in some other threads, but it doesn't seem to give any results.
Any help is much appreciated.
Use left(), like this:
=arrayformula( if( len(A2:A); iferror( vlookup( left(A2:A; 5) & "*"; F2:G; columns(F2:G); false) ); iferror(1/0) ) )
This array formula will automatically fill the whole column.
To do the same with a fill-down formula, remove the arrayformula() wrapper and use a row absolute reference, like this:
=vlookup( left(A2; 5) & "*"; F$2:G; columns(F$2:G); false)
See your sample spreadsheet for an illustration.
try in C2:
=INDEX(IF(A2:A="";;IFNA(VLOOKUP(LEFT(A2:A; 5)&"*"; F2:G12; 2; ))))

How to workaround Query with a mixed-data column? (google sheets) [duplicate]

This question already has answers here:
Query is ignoring string (non numeric) value
(2 answers)
Closed 5 months ago.
I have a simple Query that groups my data by months that was working fine before, but now that I've introduced a formula into my date column, it's not working anymore. (I'm guessing it's because the majority data in the column is now formulas instead of actual dates).
=Query(C5:L,"SELECT SUM(I) pivot MONTH(C)+1",1)
Is there a way for me to still get my intended Query data without removing my formulas in the date column? (Query formula is in M2)
Thank you in advance!
Link to sheet: https://docs.google.com/spreadsheets/d/1EpvLMboKJ0KeR7tTqBarF1AnAg3jelhKTkyBhwKNlK4/edit#gid=1335125620
Your formulas in Col C seem to be causing the issue since they're adding a blank space when there is no corresponding value in Col D:
=IF(D45=""," ",TIMESTAMP())
Instead, try:
=IF(D45="",,TIMESTAMP())

ArrayFormula with Average formula in Spreadsheet [duplicate]

This question already has answers here:
ArrayFormula of Average on Infinite Truly Dynamic Range in Google Sheets
(6 answers)
Closed 5 months ago.
So, right now im working on another spreadsheet project and this time i want to know how to use Average Formula with Array formula to make them automatically dragdown each time a new data entered.
Here is the picture from my spreadsheet. So i want to average them from Column CH to Column CL using average formula with arrayformula.
Example
I've tried all 'Averageif' or 'Average' and using arrayformula but it turns out '#DIV/0'
Can you guys please help me with it? Thankyou.
It's not going to work.
Average formula works on arrays so it won't change anything when you try nest it with arrayformula. For example. If you try to average 3 values from 3 columns, you could try: arrayformula(average(CH1:Ch,CI1:CI,CL1:CL)) but it will return the same result as average(CH1:Ch,CI1:CI,CL1:CL) - an average of all values from all 3 ranges.
I suggest workaround and make average manually (sum of elements divided by it's number):
=Arrayformula( (CH1:Ch + CI1:CI +CL1:CL)/3)
these days it can be done like:
=INDEX(IFERROR(1/(1/BYROW(OFFSET(CH2,,,
MAX((INDIRECT("CH2:"&ROWS(CH:CH))<>"")*ROW(CH2:CH)), 5),
LAMBDA(x, AVERAGE(x))))))
for more variations see: https://stackoverflow.com/a/65435321/5632629

Arrayformula with countif in google sheets to count duplicates until current row [duplicate]

This question already has an answer here:
How to combine ARRAYFORMULA and COUNTIF
(1 answer)
Closed 3 months ago.
I need to count the duplicates only until the current row. And I need it to be in an arrayformula as I need it to expand automatically when a new row is added
In excel I would use a table with a function looking something like:
=COUNTIF($A$2:A2,B2) -> in cell C2
In cell C10 the function would automatically become:
=COUNTIF($A$2:A10,B10)
I am not able to perform this action in google sheets:
=ARRAYFORMULA(IF(ROW(J:J)=1,"Column title", IF(ISBLANK(J:J),"",COUNTIF($J$1:J1,J:J))))
I know that $J$1:J1 won't work but am out of ideas.
Is this somehow achievable?
Something like this?
=ArrayFormula(if(A:A="","",countifs(A:A,A:A,row(A:A),"<="&row(A:A))))

Facing a problem with making a table in Google Sheets [duplicate]

This question already has an answer here:
Google Sheet SUMIF not summing range
(1 answer)
Closed 3 years ago.
I am making a sheet to oversee funds
I am trying to make something like this in Google Sheets
D(n) = D(n-1) + B(n) - C(n) for the entire row of D
and so on for the entire row
I also would prefer if the remaining fund didn't show up unless a value for received or spent has been input
You can use SUMIF to get running totals of columns B and C, and subtract one from the other:
=ArrayFormula(if((B3:B="")*(C3:C=""),"",sumif(row(A3:A),"<="&row(A3:A),B3:B)-sumif(row(A3:A),"<="&row(A3:A),C3:C)+D2))
try:
=ARRAYFORMULA(IF((B3:B)+(C3:C),
MMULT(TRANSPOSE((ROW(B3:B)<=TRANSPOSE(ROW(B3:B)))*B3:B), SIGN(B3:B))+D2-
MMULT(TRANSPOSE((ROW(C3:C)<=TRANSPOSE(ROW(C3:C)))*C3:C), SIGN(C3:C)), IFERROR(1/0)))

Resources