Scalable Regexmatch formular - google-sheets

i need help with the following formula:
IF(REGEXMATCH(LOWER(B3), JOIN("|",Keywords!H$2:H$13)),"unqualified","qualified")
B3 is in this Case the String "I need help". My problem is that id like to use the Formula
IF(REGEXMATCH(LOWER(B3), JOIN("|",Keywords!H$2:H)),"unqualified","qualified")
so i dont always need to match the Row with the Keywords. Otherwise i have Spaces in the join formular and the results are always "unqualified".
Does anyone has an idea how i can rewrite this formula into a more "scalable Version"?
I hope everything i explained was understandable.

Try this out. You can remove the LOWER and make the regex case insensitive
=ARRAYFORMULA(
IF(ISBLANK(B3:B),,
IF(
REGEXMATCH(
B3:B,
"(?i)"&TEXTJOIN("|",TRUE,Keywords!H2:H13)),
"unqualified",
"qualified")))

I solved my problem with this formula:
IF(REGEXMATCH(LOWER(B3), JOIN("|",QUERY(G$2:G,"select G Where G is not null"))),"unqualified","qualified")

Related

EXCEL/Google Sheets. Best way to SUM multiple VLOOKUP?

could you guys help me with a project. I was able to find a solution for my problem and the formula looks like this:
=IFERROR(VLOOKUP(E4;A8:B13;2;FALSE);0)+IFERROR(VLOOKUP(F4;A8:B13;2;FALSE);0)+IFERROR(VLOOKUP(G4;A8:B13;2;FALSE);0)
I have a category (e.g. Fruits) and need to import a sheet with different kind of fruits and non fruits. I use keywords which define what is a fruit and what not. I need to SUM all values which match to a keyword. My formula works but it will be more and more work when i need to add more keywords.
Are there a better way to realise this?
I build this example sheet for better understanding : )
Spreadsheet link
Thank you in advance : )
use:
=SUMPRODUCT(IFNA(VLOOKUP(E4:G4; A8:B13; 2; )))
you can even use E4:4 or E4:G5 or E4:5
row-wise it would be:
=INDEX(BYROW(E4:G5; LAMBDA(x; SUM(IFNA(VLOOKUP(x; A8:B13; 2; ))))))
use this
=ArrayFormula(SUM( IFERROR( VLOOKUP(E4:G4;A9:B;2;0))))
Usign sumif
=ArrayFormula(SUM(SUMIF(A9:A;"="&E4:G4;B9:B)))
Xlookup
=ArrayFormula(SUM(XLOOKUP(E4:G4;A9:A14;B9:B14;"";1)))
Us XLOOUP instead of IFERROR(VLOOKUP()) can shortens the formula.
=SUMPRODUCT(XLOOKUP($E4:4,$A$9:$A,$B$9:$B,0))

Can I use an arrayformula with a split arrayformula inside it?

Trying to break apart rows containing numbers like "198,183,158,315,274" by their comma, and then average them out and divide them by a singular number; using arrayformula. It only produces one row of result and it's incorrect though?
Here is my test sheet, editable
Thanks for any help.
try:
=ARRAYFORMULA({"Average"; IF(A4:A="",,
IFNA((MMULT(1*IFERROR(SPLIT(INDIRECT("A4:A"&
MAX(IF(A4:A="",,ROW(A4:A)))), ",")),
ROW(INDIRECT("A1:A"&COLUMNS(SPLIT(A4:A, ","))))^0)/
(1+LEN(REGEXREPLACE(A4:A&"", "[0-9\. ]", ))))/B1))})
spreadsheet demo
Another solution:
=ArrayFormula({"Average";(ArrayFormula(mmult(N(array_constrain(ArrayFormula(IFERROR(SPLIT(A4:A8,","))),MATCH(2,1/(A4:A8<>""),1),5)),sequence(Columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)/mmult(N(array_constrain(if(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))>0,1,0),MATCH(2,1/(A4:A8<>""),1),5)),sequence(columns(ArrayFormula(IFERROR(SPLIT(A4:A8,",")))),1)^0)))/$B$1})

Find Unique in google sheets - first n characters

I have a google sheet with a column (A) of urls.
Xttps://tXco/008wnbebbw
Xttps://tXco/00lR1FNKBo
Xttps://tXco/00lR1Fw9cO
Xttps://tXco/00UwZwgh2h
Xttps://tXco/00UwZwxSqR
Xttps://tXco/00UwZwxSqR
Xttps://tXco/044TcIFl72
In column B I need to find all unique urls up to the 18th character. For instance column B should show:
Xttps://tXco/008wnbebbw
Xttps://tXco/00lR1FNKBo
Xttps://tXco/00UwZwgh2h
Xttps://tXco/044TcIFl72
I have this formula which I was trying to adapt for it (not sure if it helps at all). I was trying to adapt this to use with =UNIQUE( ?
=SUMPRODUCT(--(LEFT($A$1:$A$15,18)=LEFT(A1,18)))>1
If it helps to take a look at the sheet, here it is: https://docs.google.com/spreadsheets/d/1tG7TpHNvNY86PRiePsKyKfxnuEZah6T7ZDL7dXOIcEA/edit?usp=sharing
Thanks in advance!
You may try this formula:
=ArrayFormula(vlookup(
UNIQUE(FILTER(LEFT(A2:A,17),A2:A<>"")),
FILTER({LEFT(A2:A,17),A2:A},A2:A<>""),
2,0))
How it works
it will first find unique left N chars:
UNIQUE(FILTER(LEFT(A2:A,17),A2:A<>"")
then get left N chars and original strings:
FILTER({LEFT(A2:A,17),A2:A},A2:A<>"")
and then use vlookup to get top first entry for uniques.
Try this instead without the extra column. Put it in B1:
=unique(arrayformula(if(left(A1:A,18)=left(A1:A,18),A1:A,"")))
Try this: =unique(arrayformula(left(A1:A,18)))

String manipulation on column in Google Sheet Query

Is it possible to do a string manipulation of data in a Google Sheet query?
I want to do something like the following:
=QUERY(someRange!A:Z, SELECT A, SUBSTITUTE(B, "OCH", ""))
The idea being that all rows' column B is 'OCHXXXXXXX' where X is a digit. I would like to get rid of the chars.
On a side note... Is this possible in MySQL? How?
This formula might work for you:
=QUERY({Sheet1!A:A,ARRAYFORMULA(SUBSTITUTE(Sheet1!B:B,"OCH","")),Sheet1!C:Z})
I would suggest:
=arrayformula(REGEXREPLACE(somerange!B:B, "OCH", ""))

Importrange() where the source columns/rows change

I have an importrange("key", "sheet1!D" & targetRow) formula, but I also need the column of the importrange() to be dynamic too in case I add/delete columns in the source data:
E.g. importrange("key", "sheet1!" &targetColumn &targetRow)
I researched query() language but being forced to use Col1, Col2 etc instead of named column identifiers makes this useless for what I'm trying to achieve.
Can someone help me with this? Easiest way to get column letters without a script? Thanks very much.
I've figured out a somewhat inelegant workaround:
=IMPORTRANGE("key", "Sheet!" & IMPORTRANGE("key", "Dept") & targetRow)
Where "Dept" is a single-cell named range that contains the column letter of the column I want.
The column letter (e.g. 'K') is the result of the following formula:
=substitute(address(row(K6), column(K6),4), row(K6),"")
Is there really no easier/more robust way of doing this? This will be used to calculate bonuses so it's actually a very critical spreadsheet.

Resources