简体   繁体   中英

Exclude all values in a column on a different sheet from a Google Sheets Query

So I have the following query:

=QUERY('sheet - Users'!A1:S, "Select A,B,C,F,G,O,Q,S where Q >= 44223 and not lower(O) matches '.*archived.*|.*archived' and not lower(C) matches '.*admin.*|.*admin' and not UPPER(C) matches '.*SMB.*' and not C matches '.*Shared Mailbox.*' and S >=90",1)

This works perfectly fine (as convoluted as it is), however, I have a list of exceptions that I need to remove from the results (the list could change, so ideally this needs to be dynamic and not hard coded).

I did some digging around and found this example query :

=query(C2:C8,"select C where C<>'"&JOIN("' and C<>'",D2:D10)&"'"&""

But that doesn't seem to be working for me when I try to incorporate it into my query.

The data I need to exclude is on a sheet called: Exclusion List And is in cells C2:C

Is anyone able to help?

Solution:

You can modify the exclusion list to reference C2:C from another sheet, like this:

=query(C2:C8,"select C where C<>'"&JOIN("' and C<>'",'Exclusion List'!C2:C)&"'"&""

Sample Query and Exclusion Sheet:

在此处输入图像描述

在此处输入图像描述

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