Filemaker Native CF Performance

@aptworks I love it!

Thanks, @steve_ssh and @mipiano. Here’s the much slower version, which leaves duplicates in place.

/*
CUSTOM FUNCTION: RemoveValues_PreservingDuplicates ( MyList; Out )
Debi Fuchs of Aptworks Consulting

Speedily (and with no recursion) filter values out of a list
NOTE: includes original duplicates rather than returning unique values only 
  (for an alternative see RemoveValues_ReturningUnique, which is faster)

EXAMPLE:
 RemoveValues_PreservingDuplicates( List("a";"b";"c";"d"; "a"); List("d"; "b") )
    --> "a¶c¶a¶"

CREATED: 2025-11-05

*/

Let (
  [
    ~exclusions = UniqueValues ( Out );
    ~combined = UniqueValues ( ~exclusions & MyList );
    ~keep = Right ( ~combined; Length ( ~combined ) - Length ( ~exclusions ) )
  ];
  FilterValues ( MyList; ~keep )
)

Since writing it I found a version below by “onefish” who came up with a similar function several years before me:

2 Likes

That's funny. Yesterday I looked through my FMP file of CFs to see what other CFs I had saved for the OP's task and came across OneFish's contribution as well. I had saved it back then. :slight_smile:

I've since added your lightweight option above to the 'toolbox'.

I do use Bruce's AntiFilterValues in some production solutions, as well as other similar CFs, but they're typically run on ~300-5,000 records, not 20K +. Performance hasn't really been an issue.

I'm going to compare your 'new' method in use on the case where 5,000-6,000 records per list to see if it removes the slight delay (a few seconds). However, I'll need to tweak yours a bit as we need to create a new list that shows what is missing from list_B that is present in list_A (which Bruce's and others' do fine), but I like the brevity of your line of thinking in your offering. :+1:

1 Like

+100