Google sheet arrayformula join() and split() functions - google-sheets

Does anybody know how to arrayformula this join function?
My formula is not as complex as the example here. ArrayFormula a Filter in a Join (Google Spreadsheets)
It does not contain a filter function, so I'm not sure what from that answer applies and doesn't apply.
I want to array formula this: =if(isblank(B2),,join("," ,B2:I2))
Using the normal way to array something doesn't work:
=ArrayFormula(if(isblank(B2:b),,join(",",B2:b:I2:i)))
Also for splits, I have split(B2, ",")
=ArrayFormula(split(B2:B,",")) does nothing but the first row

Maybe try:
=ArrayFormula(if(len(B2:B), B2:B&C2:C&D2:D&E2:E&F2:F&G2:G&H2:H&I2:I,))
or
=ArrayFormula(substitute(transpose(query(transpose(B2:I),,rows(B2:B)))," ",""))
or, in case you want a space between the concatenated values:
=ArrayFormula(trim(transpose(query(transpose(B2:I),,rows(B2:B)))))
For using split() in arrayformula a workaround can be found here

Related

How to use COUNTIFS with ARRAYFORMULA

I have this formula that checks for the 2nd(onwards) instance of duplicate using 2 columns. I want it to be automatically applied to new rows but can't seem to figure out how to use ARRAYFORMULA for COUNTIFS. Can anybody please help me convert this formula =COUNTIFS($K$2:$K2, $K2, $T$2:$T2, $T2)>1 to an arrayformula or something similar? Thanks!
MAP() function may be a good solution. Try-
=MAP($K$2:INDEX($K$2:$K,COUNTA($K$2:$K)),$T$2:INDEX($T$2:$T,COUNTA($K$2:$K)),LAMBDA(x,y,COUNTIFS($K$2:$K,x,$T$2:$T,y)>1))
K2:INDEX(K2:K,COUNTA(K2:K)) will return a array of range from K2 to next non empty cell of K column.
Same T2:INDEX(T2:T,COUNTA(K2:K)) will return a array of range from T column still base on K column last non empty cell.
Edit: As per comment, try below formula-
=INDEX(MAP(A2:INDEX(A2:A,COUNTA(A2:A)),C2:INDEX(C2:C,COUNTA(A2:A)),LAMBDA(x,y,COUNTIFS(A2:A,x,C2:C,y,ROW(A2:A),"<="&ROW(x))>1)))
Change ranges for your sheet.

REGEXEXTRACT and ARRAYFORMULA in Google Sheets

Hello. I'm new to regex and I've been practicing on google sheets. However, I found that only REGEXEXTRACT among the 3 regex related formulas in google sheets works incorrectly in ARRAYFORMULA. The strange thing is that by ARRAYFORMULA it is expanded in the row direction, but not in the column direction. Why is this happening?
If you are looking to return only a single column that checks for each of the conditions of regex you would have to join them together internally. Otherwise your array is expanding down and right as intended. It is checking column F against G2, then H2, then I2, therefore showing each case for each row.
=ARRAYFORMULA(REGEXMATCH($F4:$F10,JOIN("|",G$2:I$2)))
Will concatenate them in the format where the REGEX checks for each of the criteria and if ANY are true, it returns true. It essentially writes this:
=ARRAYFORMULA(REGEXMATCH($F4:$F10,"...-....-....|.com$|^!")
| - is the delimiter.
UPDATE:
I believe you're only option is to change the formatting of REGEXEXTRACT to be an array itself. Such as:
=ARRAYFORMULA({REGEXEXTRACT($F2:$F10,G$2),REGEXEXTRACT($F2:$F10,H$2),REGEXEXTRACT($F2:$F10,I$2)})

Google Sheet how to concat and calculate

I have created a sheet that generate random math questions. I'm having issue create automated answers.
google sheet concat not working
issue example 2
How do I get the result in F6? In another word, how do I get 111 in F6 instead of the math 30+81"?
If you want to get the sum of the two numbers you must use the SUM() formula in the cell you want it to get the result.
The SUM() formula is used as follows:
=SUM(number_1,number_2,number_3...)
In your case the formula would be:
=SUM(B6,D6)
After your comment:
You can use the IFS formula, its a bit tricky but it would work.
The syntaxis is this:
IFS(condition1, value1, condition2, value2, …)
To do what you want you should implement something like this:
=IFS(C6="-"; B6-D6; C6="+"; B6+D6;C6="/"; B6/D6; C6="*"; B6*D6)
This formula will check the cell operator and depending on it will perform one action or another.
You may try QUERY() function with a helper column, like this-
=query(,"Select "&D1&" label "&D1&" ''",0)
Alternatively, without a helper column, the formula would be-
=query(,"Select "&A1&B1&C1&" label "&A1&B1&C1&" ''",0)

Google Sheet Filter function and Concatenate in a Cell

To All Google Sheet Expert,
I need help to solve this problem in my google sheets.
Problem
Based on my previous search and question, I can use combination between TextJoin and Filter.
How can I achieve those expected result?
What should I fill in M4, M5, N4, N5, O4, O5?
This is link to my sheets
Thank you in advance.
One possible approach
This is for cell M3 for example:
=JOIN(
CHAR(10),
ARRAYFORMULA(
(FILTER(E3:K3, VLOOKUP(E3:K3,$A$4:$B$10,2,FALSE) = M2))
&" "&
(FILTER(E4:K4, VLOOKUP(E3:K3,$A$4:$B$10,2,FALSE) = M2))
)
)
Starting from the inner-most formulae
The VLOOKUP is needed to match the food name to the type.
This value is then used to FILTER BOTH the price and the titles of the food. You need two filters for this, one for the price and one for the title. Using onlt this it will give you:
These two rows now need to be concatenated with the & symbol, wrapped in an ARRAYFORMULA.
Finally these rows need to be joined with JOIN using a newline CHAR(10).
Reference
VLOOKUP
ARRAYFORMULA
CHAR
JOIN

How can I search a column with alphanumeric entries and return a 1 for unique with an array formula?

I need something that auto-fills for however many rows are in the spreadsheet, but I'm not sure if an array is the best way.
In my example below, I want Column C to show a 1 if the corresponding entry in Column A is unique, and a 0 if it isn't.
I had hoped it would be as easy as using ARRAYFORMULA(IF(UNIQUE(A1:A),1,0)), but forgot that IF wouldn't work with the text.
Here's my example with the most recent formula I tried.
Thank you!
Please use the following formula:
=ArrayFormula(IF(LEN(A1:A)<>0,
IF(COUNTIF(A1:A,A1:A)>1,0,1)
,""))
Functions used:
COUNTIF
ArrayFormula
LEN
You can combine ARRAYFORMULA and IF with IFERROR and COUNTIF
Sample:
=ARRAYFORMULA(IF(IFERROR(COUNTIF(A1:A,A1:A)=1,0)=TRUE,1,0))

Resources