# Remove Records from Found Set

**URL:** <https://the.fmsoup.org/t/remove-records-from-found-set/2630>\
**Category:** Questions\
**Tags:** found-set\
**Created:** [December 7, 2021, 11:50am UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630 "2021-12-07T11:50:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![steverichter](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steverichter/32/1022_2.png) [@steverichter](https://the.fmsoup.org/u/steverichter)\
**Post date:** [December 7, 2021, 11:50am UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/1 "2021-12-07T11:50:13Z")

</div>

I have a found set of customers who bought products A and B. Some bought only one, others bought both. I want to identify the customers who bought both A and B, then remove those records from the found set.

I considered using variables and a loop to compare and mark the records.

Any other suggestions?

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [December 7, 2021, 1:53pm UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/2 "2021-12-07T13:53:44Z")

</div>

My assumptions: there is a customer table; there is a purchase table; the customer and purchase tables are linked via a relationship.

Perform a find from a layout that uses the customer table. Ensure this layout has a portal that points to the purchase table. You will need three find requests: find related product A; find related product B; omit related product A AND related product B.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![AndyHibbs](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/andyhibbs/32/3089_2.png) [@AndyHibbs](https://the.fmsoup.org/u/AndyHibbs)\
**Post date:** [December 8, 2021, 7:23pm UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/3 "2021-12-08T19:23:12Z")

</div>

Are you able to search on both product A and product B, then use a Constrain Find?

---

<div class="post-metadata">

**Author:** ![steverichter](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steverichter/32/1022_2.png) [@steverichter](https://the.fmsoup.org/u/steverichter)\
**Post date:** [December 9, 2021, 2:16am UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/4 "2021-12-09T02:16:35Z")

</div>

To clarify, I have a customer table and a purchase table. Here is what worked:

Go to purchase table and clear flags  
Find product A _OR_ B  
Find duplicate (!) customer records and constrain  
Set a flag on these records  
Find product A _AND_ empty (=) flags

The resulting found set is customers who bought product A but not product B.

I could not get the previous suggestions to work. I believe the reason is that the omit and constrain commands will only work with a single criteria.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [December 9, 2021, 2:27am UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/5 "2021-12-09T02:27:43Z")

</div>

> [@steverichter](#):
>
> I could not get the previous suggestions to work. I believe the reason is that the omit and constrain commands will only work with a single criteria.

The omit requests must be the last requests of a set of find requests. You can omit multiple "and" and "or" requests that way. Constrain found set also works with multiple criteria.

---

<div class="post-metadata">

**Author:** ![steverichter](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steverichter/32/1022_2.png) [@steverichter](https://the.fmsoup.org/u/steverichter)\
**Post date:** [December 9, 2021, 2:29am UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/6 "2021-12-09T02:29:46Z")

</div>

> [@bdbd](#):
>
> The omit requests must be the last requests of a set of find requests. You can omit multiple "and" and "or" requests that way. Constrain found set also works with multiple criteria.

I’ll try that methodology again, then — I must have made an error in my scripting. I appreciate your assistance.

---

<div class="post-metadata">

**Author:** ![steverichter](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steverichter/32/1022_2.png) [@steverichter](https://the.fmsoup.org/u/steverichter)\
**Post date:** [December 9, 2021, 1:09pm UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/7 "2021-12-09T13:09:29Z")

</div>

I’ve experimented with constrain and omit. I can successfully create various found sets when I’m constraining/omitting based on multiple fields (e.g., customerNo and productName).

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![FabriceN](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/fabricen/32/2506_2.png) [@FabriceN](https://the.fmsoup.org/u/FabriceN)\
**Post date:** [December 16, 2021, 12:14pm UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/8 "2021-12-16T12:14:46Z")

</div>

I don't believe there is a "native" way do do this with find, provided that the product information is in the product table or order lines.  
The ! operator is of no use in that situation.  
I think this is one of the rare situations where you need to search on an unstored calc (or loop if there is a risk because of the database size/number of users.

So:  
1 - find the ones that have bought A or B  
2 - loop through records and omit the ones that have bought both. (or constraint on an unstored calc)

---

<div class="post-metadata">

**Author:** ![steverichter](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steverichter/32/1022_2.png) [@steverichter](https://the.fmsoup.org/u/steverichter)\
**Post date:** [December 16, 2021, 11:35pm UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/9 "2021-12-16T23:35:34Z")

</div>

> [@FabriceN](#):
>
> The ! operator is of no use

Yes, I found out ! didn’t work. Ultimately, I was able to do a search for A and save the customer\_IDs into a variable. Then, I did the same for B. I could then compare $ListA to $ListB and find the set of records I wanted.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [December 17, 2021, 1:04am UTC](https://the.fmsoup.org/t/remove-records-from-found-set/2630/10 "2021-12-17T01:04:28Z")

</div>

One more alternative:

In the Purchases table:

- create two find requests: find A and find B
- perform find
- sort by customer ID
- for each customer:
  - is the summary group of records greater than one?
    - Yes: do those records contain both A and B?
      - Yes: omit the group
