Brian Dunning's FileMaker Custom Functions

FilterList ( ListA ; Attribute ; ListB ; CaseSensitive )

to compare and filter values, lists with different attribute : Equals - NotEquals - Contains - NotContains - BeginsWith - NotBeginsWith - NotEndsWith - EndsWith

  Average rating: 4.3 (82 votes) Log in to vote

Agnes Barouh   Agnes Barouh - Show more from this author
Tic Tac
http://www.tictac.fr/CoinFileMaker/Page.html

Share on Facebook Share on Twitter

  Sample input:
FilterList ( "One¶Two¶three¶Four¶five" ; "BeginsWith" ; "F¶t" ; 1 )
  Sample output:
three¶Four

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

- - **calculation modified the 05/09/11 **- - ** update in the code for filter # or | or [ and ]

- - **calculation modified the 06/29/09 **- - ** Major-update in the code for greater speed (I see trouble with Evaluate and substitute, when search is in the first caractere of the list : search is "Contains z" and the list are zGlobalA¶zGlobalB¶zGlobalC ...) ok now

- - **calculation modified the 09/29 **- - ** no return Tag ( #|# ) when attribut is Equal and caseSensitive is < 1
- - **calculation modified the 31/05 **- - ** Change one substitute (case "not" )
- - **calculation modified the 27/05 **- - ** Change Tag | -> #|#
- - **calculation modified the 25/10 **- - ** Change :Addition of NotBeginsWith and NotEndsWith ** Change : remove the final ¶ when I used FilterValues **
- - **calculation modified the 15/04/08 **- - ** IF isEmpty listA or isEmpty ListB

Not recursive Function - Optional Parameters : Case Sensitiveness ( boolean format or null )


* FilterList () requires CustomList ( start ; End ; Function )
http://www.briandunning.com/cf/868

-> Attributes :
Equals - NotEquals - Contains - NotContains - BeginsWith - NotBeginsWith - NotEndsWith - EndsWith
-> CaseSensitive :
Boolean

----------------------------------------- *
FilterList ( "Thank¶you¶very¶much¶ Ugo Di Luca ¶And¶Fabrice Nordmann" ; "BeginsWith" ; "ve¶mu" ; "" )
----------------------------------------- *

----------------------------------------- more examples

FilterList ( FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ; "NotContains" ; "Z¶zkp¶_" ; 1 )
Result = FieldNamesList Without the field whose name contains Z, zkp or _

FilterList ( Texte ; "Contains" ; "$¶_" ; 0 )
Result = values list With contains $ or _

FilterList ( LayoutNames ( Get ( FileName ) ) ; "EndsWith" ; "Dev" ; 1 )
Result = LayoutNames list whose the end name is Dev

FilterList ( List ( Table::MyField ) ; "Contains" ; Left ( FieldX ; 1 ) & ¶ & Middle ( FieldY ; 3 ; 3 ) ; "" )


----------------------------------------- more détails

--------- CaseSensitive = empty or 0

FilterList("One¶Two¶three¶Four¶five";"Equals";"One¶four";"" or 0 ) | Result => "One¶Four"
FilterList("One¶Two¶three¶Four¶five";"NotEquals";"One¶four";"" or 0 ) | Result => "Two¶three¶five"
FilterList("One¶Two¶three¶Four¶five";"Contains";"O¶t";"" or 0 ) | Result => "One¶Two¶three¶Four"
FilterList("One¶Tow¶three¶Four¶five";"NotContains";"O¶t"; "" or 0 ) | Result => "five"
FilterList("One¶Two¶three¶Four¶five";"BeginsWith";"F¶t";"" or 0 ) | Result => "Two¶three¶Four¶five"
FilterList("One¶Two¶three¶Four¶five";"NotBeginsWith";"F¶t";"" or 0 ) | Result => "One"
FilterList("One¶Two¶three¶Four¶five";"EndsWith"; "o¶E";"" or 0 ) | Result => "One¶Two¶three¶five"
FilterList("One¶Two¶three¶Four¶five";"NotEndsWith"; "o¶E";"" or 0 ) | Result => "Four"

--------- CaseSensitive = 1

FilterList("One¶Two¶three¶Four¶five";"Equals";"One¶four" ; 1 ) | Result => "One"
FilterList("One¶Two¶three¶Four¶five";"NotEquals";"One¶four" ; 1 ) | Result => "Two¶three¶Four¶five"
FilterList("One¶Two¶three¶Four¶five";"Contains";"O¶t"; 1 ) | Result => "One¶three"
FilterList("One¶Two¶three¶Four¶five";"NotContains";"O¶t" ; 1 ) | Result => "Two¶Four¶five"
FilterList("One¶Two¶three¶Four¶five";"BeginsWith";"F¶t"; 1 ) | Result => "three¶Four"
FilterList("One¶Two¶three¶Four¶five";"NotBeginsWith";"F¶t"; 1 ) | Result => "One¶Two¶five"
FilterList("One¶Two¶three¶Four¶five";"EndsWith";"o¶E"; 1 ) | Result => "Two"
FilterList("One¶Two¶three¶Four¶five";"NotEndsWith";"o¶E"; 1 ) | Result => "One¶three¶Four¶five"


 

Comments

Matthew Fero   Matthew Fero, Seattle
Aug 7, 2011
Note: To install this custom function you must first install a second custom function called "CustomList".

See: http://www.briandunning.com/cf/868
 
CesarRG   CesarRG, Oviedo (Spain)
May 31, 2013
Hello,

The function does not work well if the second list contains nothing. In this case the function returns the first result list.
 
Agnès   Agnès, Paris
May 31, 2013
Hello,

Yes, is my choice when I wrote this function : the calc are
" IsEmpty ( ListB ) ; ListA ;"

There was a discussion about it on the forum French, what is the logical result if ListB was empty... you can not put "IsEmpty (ListB), "";" because the result must depend on the selected attribute and I did not want to burden the already complicated calculation.
For Equal : IsEmpty ( ListB ) ; ""
For Not Equal : IsEmpty ( ListB ) ; ListA ;
For Contains or Not Contains.... What should be the result... The same for the other.

The easiest way was for me to decide if ListB was empty, the result was ListA.

But you may be right, I do not know.

Agnès
 
Dave   Dave, Birmingham, AL
Jun 12, 2015
Will this function accept global variables ($$myVariable) as ListA or ListB?
 
Jonathan Mickelson   Jonathan Mickelson
Apr 17, 2019
Great function! Excellent work Agnès, as always!
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: