Answers.Body: <p>You should use the custom search "Include / Exclude Search" that does exactly what you want</p>
  
  <p>civicrm/contact/search/custom?csid=4&amp;reset=1 on my install, likely the same custom search id on your install</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-23T09:48:23.857Z
Answers.Text: This should be the accepted answer. Extremely useful, but kinda hidden, search function.
Answers.UserDisplayName: thoni56
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-12T13:52:28.563Z
Answers.LastActivityDate: 2015-10-12T13:52:28.563Z
Answers.UserDisplayName: Xavier
Answers.Body: <p>The issue with the Search Builder is that it's not doing an exclude when you say NOT IN. Instead, it's selecting contacts who have any tag besides the one you listed.</p>
  
  <p>This is because groups and tags are entities themselves, and contacts may be related to an unlimited number of them.  Having a tag that is not X is a different thing than not having the tag X.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-13T01:04:57.310Z
Answers.LastActivityDate: 2015-10-13T01:04:57.310Z
Answers.UserDisplayName: Andie Hunt
Body: <p>It seems that it's not possible to find contacts who are in group A, but not in group B. The only place where it's possible to exclude a group is Search Builder, but when I give two criteria (contact is in group A) and (contact is not n group B) CiviCRM ignores the second clause.</p>
  
  <p>I tried to convert the second clause to use a Tag. So I've created a tag for group B, and searched for contacts in group A and contacts not in tag B.</p>
  
  <p>The result is really puzzling, and it seems I am not following CiviCRM's logic:</p>
  
  <p><a href="https://i.sstatic.net/JPjxQ.png" rel="noreferrer"><img src="https://i.sstatic.net/JPjxQ.png" alt="CiviCRMS logic"></a></p>
  
  <p>(this is polish l10n, but "Etykieta" and "Kategorie" are both translations for "Tag")
  Could someone clarify, what is happening here?</p>
  
Tags: <search><groups><tags>
Title: Excluding in search doesn't work
ThreadText: # Excluding in search doesn't work
  
  (Asked by: username_0 on 2015-10-12)
  
  It seems that it's not possible to find contacts who are in group A, but not in group B. The only place where it's possible to exclude a group is Search Builder, but when I give two criteria (contact is in group A) and (contact is not n group B) CiviCRM ignores the second clause.
  
  I tried to convert the second clause to use a Tag. So I've created a tag for group B, and searched for contacts in group A and contacts not in tag B.
  
  The result is really puzzling, and it seems I am not following CiviCRM's logic:
  
  [![CiviCRMS logic](https://i.sstatic.net/JPjxQ.png)](https://i.sstatic.net/JPjxQ.png)
  
  (this is polish l10n, but "Etykieta" and "Kategorie" are both translations for "Tag")
  Could someone clarify, what is happening here?
  
  **Tags:** search, groups, tags
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-10-12. Score: 9
  
  You should use the custom search "Include / Exclude Search" that does exactly what you want
  
  civicrm/contact/search/custom?csid=4&reset=1 on my install, likely the same custom search id on your install
  
  > **Comments:**
  > **username_2**: This should be the accepted answer. Extremely useful, but kinda hidden, search function.  
  
  ---
  
  ### Answer by username_3 on 2015-10-13. Score: 4
  
  The issue with the Search Builder is that it's not doing an exclude when you say NOT IN. Instead, it's selecting contacts who have any tag besides the one you listed.
  
  This is because groups and tags are entities themselves, and contacts may be related to an unlimited number of them. Having a tag that is not X is a different thing than not having the tag X.
  
  
  ---
  
  