Google-sheets – Google Sheets intersection query

google sheetsgoogle-sheets-query

I'm trying to write an intersection query in Google Sheets that lists all the rows in sheet 1 that contain a cell in sheet 1, column A, that matches at least one cell in sheet 2, column P

This is the first time I've tried writing a more advanced formula on Google Sheets, using a combination of Sheets functions and the Google Visualization API Query Language. I'm just starting to learn the syntax and everything and I'm sure I'm messing things up so I hope someone can point out what I'm doing wrong. My current query is:

=QUERY('Sheet1'!A1:T, "SELECT * WHERE (VLOOKUP(A, 'Sheet2'!P, 1, FALSE) IS NOT NULL)", 1)

Best Answer

Michael, try this for your QUERY():

=ArrayFormula(QUERY({IF(NOT(ISERROR(VLOOKUP(Sheet1!A:A,Sheet2!P:P,1,FALSE))),Sheet1!A:T,"")}, "Select * Where Not Col1 = ''"))