I'm trying using match function to search in 2 column but match only run in 1 column. Is there any way to using match with multiple column range?
try:
=ARRAYFORMULA(REGEXMATCH(C2:D5&"", A1&""))
or:
=ARRAYFORMULA(REGEXMATCH(C:D&"", A1&"")*ROW(A:A))
or:
=ARRAYFORMULA({MATCH(A1, C:C, 0), MATCH(A1, D:D, 0)})
or:
=ARRAYFORMULA(TRIM(QUERY(IFERROR(1/(1/(REGEXMATCH(C:D&"", A1&"")*ROW(A:A)))),,9^9))*1)
Related
I want to use a formula to find the highest N values in each group in a Google Spread Sheets.
I tried this formula from infoinspired.com (credit to Prashanth):
=ArrayFormula(QUERY({SORT(A2:B;1;true;2;false);IFERROR(row(A2:A)-match(query(SORT(A2:B;1;true;2;false);"Select Col1");query(SORT(A2:B;1;true;2;false);"Select Col1");0))};"Select Col1,Col2 where Col3<3"))
But all it return is an Array_Literal error:
This is what I expect:
What is wrong with it?
You have to put a comma, not a semi colon before IFERROR. It's creating two columns, one twice larger than the other instead of three columns ;)
=ArrayFormula(QUERY({SORT(A2:B,1,true,2,false),IFERROR(row(A2:A)-match(query(SORT(A2:B,1,true,2,false),"Select Col1"),query(SORT(A2:B,1,true,2,false),"Select Col1"),0))},"Select Col1,Col2 where Col3<3"))
alternative formula:
=QUERY(SORT({{A2:B}\MAP(A2:A;B2:B;lambda(ax;bx;IFERROR(Rank(bx;Filter(B$2:$B;A$2:$A=ax);0);IFERROR(1/0))))};1;0;3;1);"Select Col1, Col2 Where Col3<3")
-
I have values in column B and C. All except 4 from column B should have a matching pair in one of the rows from column C.
I tried to use the code =FILTER(B:B, ISNA(MATCH(B:B, C:C, 0))) but that only shows me 7 matching values. Any idea why it's not matching the 75 of 79 values?
Use this formula
=BYROW(B1:B, LAMBDA(x, IF(x="",,IFNA(INDEX( C1:C, MATCH(x, C1:C, 0), 1),"Missing"))))
Find missing
=IFERROR(FILTER(B:B, ISERROR(MATCH(B:B,C:C , FALSE))), "No match")
So I've been struggling with this one query:
Column A
--
usa-persona
ind-personb
kor-personc
jpn-persond
Column B
--
usa-persona
ind-personb
ind-personb2
ind-personb3
Desired Output
--
ind-personb2
ind-personb3
Search through column B,
Return ones that have the string 'ind',
But they should not be in Column A.
This is what I have, which doesn't seem to do the last part (checking to see if they are in Column A).
QUERY(A:B, "SELECT B where B contains 'ind' and not B matches '"&A:A&"'"))
How do I go about this?
Use filter(), like this:
=filter( B2:B, search("ind", B2:B), isna(match(B2:B, A2:A, 0)) )
use:
=FILTER(B1:B; NOT(COUNTIF(A1:A; B1:B)))
I have two columns of values of which the second includes a subset of the first. I'm parsing partial matches from the first column with:
=query(A:A, "select A where A ends with 'x'")
It works fine. How would you modify it in order to exclude the shared values?
Here's an example:
A is where we're parsing from, B is the subset we want to discard, C would be the desired result:
filter values to exclude common values with column B
return only values ending in 'x'
Edit
To solve this, you first may need to exclude values from column B, then query result to match only pattern '%x'. Try this formula:
=QUERY(FILTER(A:A,REGEXMATCH(A:A,JOIN("|",FILTER(B:B,B:B<>"")))=false),
"select Col1 where Col1 like '%x'")
Edit #2
Special symbols for regular expressions are \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
If such symbols are met in your data, you need to escape them by \ in order to use regular expressions. So formula REGEXMATCH in this case won't work properly if column B contains special symbols. Possible solution is to replace them like this: [symbol] → [\symbol]. For example, to replece ():
=REGEXREPLACE(text ;"(\(|\)|\*)";"\\$1")
Try using this formula in column C to get the result:
=QUERY(FILTER(A:A,REGEXMATCH(A:A,
REGEXREPLACE( JOIN("|",FILTER(B:B,B:B<>""));"(\(|\)|\*)";"\\$1"))=false),
"select Col1 where Col1 like '%x'")
Original answer
may be using not keyword will work:
=query(A:A, "select A where not A ends with 'x'")
the same as:
=query(A:A, "select A where not A like '%x'")
I'm doing this query at my google spreadsheet:
=QUERY(H4:L35;"select sum(L) where H='First Week'"; -1)
But it returns a little table with "sum" as header and result below it. What I want is just the result! How I remove header? Can I?
Try this:
=QUERY(H4:L35,"select sum(L) where H='First Week' label sum(L) ''")
=QUERY(QUERY(A1:D, "SELECT *", 1), "SELECT * OFFSET 1", 0)
The outer query: "SELECT * OFFSET 1" excludes the first row (the header).
The inner query explicitly specifies one row of headers (via the third argument supplied to QUERY), whilst the outer query specifies none.
=INDEX(QUERY(H4:L35;"select sum(L) where H='First Week'"; -1),2,1)
This just parses the returned array and selects the 2nd record returned in the first column.
You can also do this with the filter function which is less compute intensive.
=SUM(FILTER(L4:L35, H4:H35 = "First Week"))
I have a QUERY which is returning the top 3. I could not get this to work when returning multiple rows. I ended up just hiding the row with the formula and only the answers show now.
For queries using pivot, try using INDEX to remove headers from the pivoted columns.
=INDEX(QUERY('Class hours'!A2:C11,
"select sum(C)
where A = '"&A5&"'
group by A
pivot B"), 2)
Got the answer from this thread:
https://stackoverflow.com/a/63468791/5424088
... or this
=QUERY(QUERY(H4:L35;"select sum(L) where H='First Week'"),"OFFSET 1",0)
This is more concise when ALL label classes are not wanted.
Note that 'select' and 'where' classes are not required in the second QUERY statement.
Instead of labeling column names as blanks using '', you can omit all headers like this:
=QUERY(H4:L35,"select sum(L) where H='First Week'", 0)
See the format here.
Example:
=QUERY(B4:C38,
"SELECT C, sum(B) where C!='' group by C label C 'Member', sum(B) 'Sum'"
)