How to find if string contains a specific word in Google Sheets - google-sheets

I have one column with comma separeted strings and a several with words that can be in these strings. I have to find if a a word from a column name is in a string. I used a regexmatch formula, but it doesn't distinguisch TV from TV remote. How can I fix this?
Mu formula:
arrayformula(if(L1<>"";if(REGEXMATCH($K$2:$K;L$1)=TRUE;"Wybrano";"");""))
My data
Or if it will be simplier I have to count how many times the certain word occured in the column with strings.

Can you try:
=MAKEARRAY(ROWS(K2:INDEX(K2:K;ROW(LOOKUP("ZZZ";K:K))));COUNTA(L1:1);LAMBDA(r;c;IF(LEN(INDEX(K2:K;r));IF(REGEXMATCH(INDEX(K2:K;r);INDEX(L1:1;;c)&"(?:,|$)");"Wybrano";);)))
Adjust the column range here COUNTA(L1:1) to something like COUNTA(L1:P1) or so depending on your dataset.

try:
=IFNA(BYCOL(L1:P1, LAMBDA(y, BYROW(K2:K, LAMBDA(x,
IF(MATCH("*"&y&"*", x, ), "Wybrano"))))))

Related

Google Sheets - filter multiple columns if contains text

I want to filter rows that contain a word in any column (among other text, not an exact match).
E.G.: I'd like to filter any line where the word "blue" appears in any column
you can try:
=QUERY((BYROW(A2:C, LAMBDA(acx,IF(REGEXMATCH(TEXTJOIN("|",1,INDEX(SUBSTITUTE(acx," ","|"))),"blue"),acx,)))),"Select * Where Col1!=''")
-
You can use this, it should work with as many column as you have. Let me know!
=FILTER(A:C,BYROW(A:C,LAMBDA(each, REGEXMATCH (CONCATENATE(each),"blue"))))
FILTER() with MMULT() may work. Try-
=FILTER(A2:C7,MMULT(INDEX(--ISNUMBER(SEARCH(E1,A2:C7))),SEQUENCE(COLUMNS(A2:C7),1,1,0)))
You can use E1 as filtering criteria. So make E1 a dropdown and select your desired word on E1 to filter from any column.
You can simplify above formula by using BYROW(). Try-
=FILTER(A2:C7,BYROW(A2:C7,LAMBDA(x,ISNUMBER(SEARCH(E1,JOIN("|",x))))))

Error in number formatting in Google Sheet

I need to format the numbers in a column like this:
08146.000331/2021-32
But, when I use the following format
00000"."000000"/"0000"-"00
The result is
08146.000331/2021-30
What am I doing wrong?
There is a formula to achieve the aimed result?
This is the actual sheet: link
Some of the values in column C are numbers and some are text strings that look like numbers.
Click in column C and choose Insert > Column right to create a new column D. Then insert this formula in cell D4:
=arrayformula(
{
"Formatted SEI";
regexreplace(trim(C5:C); "^(\d{5})(\d{6})(\d{4})(\d{2})$"; "$1.$2/$3-$4")
}
)
The formula converts all values to text strings and inserts separators.
Try
000"."000"."000"-"00 ---> for CPF, and
00"."000"."000"/"0000"-"00 ---> for CNPJ.
For numbers with more then 14 digits, this type of formatting don't works due to numeric precision limit.
Um abraço.

Filter a string based on a variable number of substrings in Google Sheets

I have a cell with a variable number of substrings separated by a comma.
To search:
"first,second,third"
"primero,segundo,tercero,cuarto"
"eins,zwei"
and I have a column with many strings that are composed by some of the substrings:
Column with full items
"first,second,third,fourth"
"primero,segundo,tercero,cuarto,quinto"
"primero,tercero,cuarto"
"eins,zwei,drei"
...and so on...
I would like to find the items of the Column above which has the substrings to be searched. Not a big issue when the amount of substrings is fixed but when it varies it becomes harder. I have a horrible formula that counts the number of commas and then it uses IF for each amount of substrings to search and several FIND(index(SPLIT(A4,","),2) for each substring. The formula is gigant and hard to handle.
Can you think of a better way of doing it?
Here there is an example of what I would like to do. The blue cells are the ones that should have the formula.
https://docs.google.com/spreadsheets/d/1pD9r4JF48cVSNGqA4D69lSyasWxTvAcOhWWu1xW2mgw/edit?usp=sharing
Thanks in advance!
Thank you all for your help! In the end, I used the QUERY function.
=QUERY(E:F,"select E where F contains '" & textjoin("' AND F contains '",TRUE,split(A2,",")) &"'" )
If you are interested, you can see the solution applied in the original spreadsheet :)

Excel Combine two columns in call to function?

My spreadsheet looks like this:
I have two lists of dates, I want to get all unique dates between Dates1 and Dates2 and put them in column C.
I can get unique dates in column A with UNIQUE(A2:A4), but I want all unique dates between both columnms. When I try to do =UNIQUE(A2:A4,B2:B5) I get the error:
Wrong number of arguments to UNIQUE. Expected 1 arguments, but got 2 arguments.
How can I get all unique dates between both? I've also tried concatenate, but that just gives me a huge number, not a row of dates.
Thanks!
unique formula can only work with single column. Try this formula:
=UNIQUE({A2:A4;B2:B5})
{ } will convert 2 columns into one: {A2:A4;B2:B5}
See more info here:
https://support.google.com/docs/answer/6208276?hl=en
Put all cells on the argument ie UNIQUE(A2:B5)
For seperate columns, create a dummy column next to the one you are comparing to, set its contents to the actual column, then use Unique
Use iferror to pass processing to a second version of a 'unique list' formula with different columns.
=IFERROR(INDEX(A$2:INDEX(A:A, MATCH(1E+99, A:A)), MATCH(0, COUNTIF(D$1:D1, A$2:INDEX(A:A, MATCH(1E+99, A:A))), 0)),
IFERROR(INDEX(B$2:INDEX(B:B, MATCH(1E+99, B:B)), MATCH(0, COUNTIF(D$1:D1, B$2:INDEX(B:B, MATCH(1E+99, B:B))), 0)), TEXT(,)))
Turns out (thanks to Keatinge) that UNIQUE takes an array of ranges separated by a semi-colon and wrapped in braces. Putting the range limiters from my own solution in achieves:
=unique({A$2:INDEX(A:A, MATCH(1E+99, A:A));C$2:INDEX(C:C, MATCH(1E+99, C:C))})
That sample google-sheets is here.

Google Spreadsheet Function That Sums Numbers In A Column When the Row Contains An EXACT Text

I've been at this problem for a while now. I am trying to sum numbers under a specific column when the rows equal a certain text and then display that sum on a different sheet. So far I came up with this formula: =IF(EXACT(A2,Table!A2:A)=TRUE,SUM(Table!C2:C)); however the only problem is that is sums everything in column C (which makes sense).
I wish there was a way to do something like the following: SUM(Table!C2:C where EXACT(A2,TABLE!A2:A)=TRUE). I've also tried the SUMIF(), DSUM(), and QUERY() functions to no avail. I must be getting logically tripped up somewhere.
Figured it out: =SUM(FILTER(Table!E4:E, EXACT(Table!A4:A,A4)=TRUE)).
=sum ( FILTER (b1:b10, a1:a10 = "Text" ) )
// the above formula will help you to take the sum of the values in column B when another column A contain a specific text.
The formula is applicable only in Google Spreadsheets

Resources