简体   繁体   中英

Google sheets =QUERY() matching names on two sheets

I've hesitated to ask since this seems so simple of a formula but I've been having difficulty getting it to function. Data is imported from a different workbook to sheet1 and a different set of data is imported to sheet2. Now, I am attempting to compile data by matching column E of sheet1 with column D of sheet2 (Both columns contain names) and inputting it into sheet3 of the same workbook. Pending a match, I'm attempting to display only the pertinent data that I need for records (Columns A(date), H(number), F(number), S(text)).

=QUERY(Sheet1!A:S,"select A, H, F, S where E matches '"&Sheet2!D:D&"'",1)

This returns the heading of the requested columns, but does not display any matching information (which from a manual count there should be 5 rows displayed). Ive fiddled with different formulas to include Indexes and Filters but I cant seem to get the format down to get close to replicating what I currently have. I'm assuming the issue lies in [where E matches '"&Sheet!2D:D&"'"]. Is this comparing the length of the two columns rather than the values located in the columns? Do I need to index the columns first?

try:

=QUERY(Sheet1!A:S,
 "select A,H,F,S 
  where E matches '"&TEXTJOIN("|", 1, Sheet2!D:D)&"'", 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM