1

I have two Google sheets. Sheet1 are the employees, Sheet2 are the job titles, and Sheet3 I would like to find all employees with the specified job titles.

Sheet1 (thousands of rows)
enter image description here

Sheet2 (there are over 100 different)
enter image description here

Sheet3 (expected output of Sheet1 using terms from Sheet2)
enter image description here

Trying to figure it out and so far no luck trying something like =query('Sheet1'!1:100000, "Select \* Where LOWER(F) = LOWER('Sheet2!'2:300)")

Demo sheet

2
  • Do you means that you want to output only Employee data with Job Tiltles in the list of Sheet 2, right? Commented Nov 10, 2022 at 4:00
  • @Ping Sheet1 has the data, Sheet2 has the search queries. Query Sheet1 using Sheet2 and display on Sheet3 Commented Nov 10, 2022 at 14:49

2 Answers 2

1

Try below query-

=QUERY(Sheet1!A:C,"select * where B matches '" & TEXTJOIN("|",TRUE,Sheet2!A2:A) & "'",1)

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

FILTER() with COUNTIFS() should also work.
Thanks. It works. But is there a limit on TEXTJOIN? My query works at =QUERY(Sheet1!A1:G17430,"select * where F matches '"& TEXTJOIN("|",TRUE,Sheet2!A2:A183) &"'",1) . Have 231 rows in Sheet2
Yes. There is limit. See this post please. support.google.com/docs/thread/90475863/…
If limit exceed then we have to go with FILTER().
0

result

try this:

=ArrayFormula(QUERY({$A$1:$C,XLOOKUP($B:$B,sheet2!$A$2:$A$8,sheet2!$A$2:$A$8,"")},
"SELECT Col1,Col2,Col3 WHERE Col4 IS NOT NULL",1
))

You can always pre-process the data range of a query.

4 Comments

This would only work within the same sheet but I am trying to use data from Sheet2 to Query Sheet1 then display the results on Sheet3
... there is no difference, you can name the reference range to whatever you like. I think you do know the basic of how excel and spreadsheet reference range works, right? I put the result in the same page is because it is easier to compare with the original data.
This is as simple as giving the reference range a sheet name. =ArrayFormula(QUERY({sheet1!$A$1:$C,XLOOKUP(sheet1!$B:$B,sheet2!$A$2:$A$8,sheet2!$A$2:$A$8,"")}, "SELECT Col1,Col2,Col3 WHERE Col4 IS NOT NULL",1 ))
Thanks. I noticed the issue that was stopping mine from working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.