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)})
Related
This question is also answered here:
Get a vlookup of a cell after split in Google sheet
but not marked as corrected answer, and cannot make it work.
Goal : I want to apply a vlookup function to a split function, so that I can search for corresponding values (found by the vlookup) for each token obtained from a string.
Consider this sheets:
// Sheet 'veggies'
A
apple, pine, tree
pine
// Sheet 'themes':
A
B
C
apple
8
theme1,theme2
tree
3
theme2
pine
1
theme1,theme3
I want to:
split cells of column A of 'veggies' by commas, so to have tokens
vlookup for the C column in 'themes' sheet, by using the index of tokens, for all of them
As approach I tried to first retrieve the frequences of tokens in column B, sheet 'themes', and cannot understand what my formula is doing:
=ARRAYFORMULA( VLOOKUP( split(A2;",");'themes'!A$2:D;2;FALSE))
This formula only get the frequency from column be for the first token, while for others will only report N/A saying could not find a value, but it is clearly there.
Any help?
Am I on the right track ?
P.s. if one would like to offer use of query , like in the other SO answer, please help me to break down what it does.
ARRAYFORMULA( VLOOKUP( split(A2;",");'themes'!A$2:D;2;FALSE))
Your formula works. But when splitting by comma , there's a extra space left over in all the elements from the second element. So, when
apple, pine, tree is splitted, it becomes apple, pine, tree(note the extra space prefix). To fix, you can simply add a space to the split as well:
=ARRAYFORMULA( VLOOKUP( split(A2;", ");'themes'!A$2:D;2;FALSE))
this should work if you want the results in one cell.
=ARRAYFORMULA(TEXTJOIN(", ";TRUE;IFERROR(VLOOKUP(SPLIT(A2;", ";0);themes!A:C,2,0))))
Use this formual
=ArrayFormula(LAMBDA(v,
IF(v="",,{v,SPLIT(VLOOKUP(v,themes!A2:C,3,0), ", ",1)}))
(FLATTEN(IF(A2:A="",,SPLIT(A2:A, ", ", 1)))))
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
I'm having trouble with HLOOKUP in Google Sheets. I'm trying to determine whether an inputted word is unique in a row and for this reason my formula searches combined ranges [that exclude itself] within an HLOOKUP. This is the formula I'm using [in cell E4]:
=HLOOKUP(E2, {B2:D3;F2:M3}, 2, false)
Doubtless, there's something I'm doing wrong, because I keep getting this error:
"HLOOKUP evaluates to an out-of-bounds range"
What I want to happen is that it will find a match for "ice" in the range to the left [B2:D3] and the range to the right [F2:M3]...
Confusingly, the equivalent formula works for VLOOKUP, but not HLOOKUP. I've found it also works in HLOOKUP if I search for a single range [ie B2:D3] and not a combined range.
So I'm a bit stuck. The combined range search works fine in VLOOKUP, but perhaps I need to write it differently for HLOOKUP?
Any help would be greatly appreciated.
instead of this:
=HLOOKUP(E2, {B2:D3; F2:M3}, 2, 0)
try this:
=HLOOKUP(E2, {B2:D3, F2:M3}, 2, 0)
For identifying duplicates conditional formatting might suit you. Select all relevant columns : Format > Conditional formatting..., Format cells if... Custom formula is and:
=countif(1:1,A1)>1
with formatting of your choice.
This should format all instances of any value repeated in its row.
I'm trying to embed a countif into an array formula in Google Sheets. I'm using the countif command to count the number of cells on another page with a given text string, stored in column B. Column B just contains a list of titles. The concatenate portion does a general keyword lookup.
Here is the formula that does not work. It just returns a 0 in each cell, which tells me the countif statement is failing.
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*"))),""))
If I pull out the countif statement, it works fine by itself.
=COUNTIF(Registrations!C:C,(CONCATENATE("*", B2, "*")))
I have even tried referencing B2:B in place of the B2 cell reference, but that does not work. What did I do wrong in the array formula statement?
Have you tried using & instead of the CONCATENATE function and referencing to B2:B in place of only B2?
The formula should look like this:
=arrayformula(IF(B2:B<>"",COUNTIF(Registrations!C:C,("*" & B2:B & "*")),""))
It works for me.
This is my 'Registrations' sheet:
And this is the sheet where the formula is written:
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