Brian Dunning's FileMaker Custom Functions

ValuesIntersection ( ValuesListA ; ValuesListB ; passNullStringHere )

Returns the Values that are in BOTH ValuesListA and ValuesListB.

  Average rating: 4.8 (18 votes) Log in to vote

Hal Gumbert   Hal Gumbert - Show more from this author
CampSoftware
http://www.campsoftware.com

Share on Facebook Share on Twitter

  Sample input:
ValuesIntersection ( "1¶2¶3¶4¶5" ; "4¶2¶3" ; "" )
  Sample output:
2¶3¶4

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

ValuesIntersection ( ValuesListA; ValuesListB; passNullStringHere )

Hal Gumbert, http://campsoftware.com

Returns the Values that are in BOTH ValuesListA and ValuesListB.

Parameters:
ValuesListA = List of Return delimited data.
ValuesListB = List of Return delimited data.
passNullStringHere = Pass in "" as it's used to store the list of Values in both ValueLists.

Return Value:
The Values that are in BOTH ValuesListA and ValuesListB

Input: ValuesIntersection ( "1¶2¶3¶4¶5" ; "4¶2¶3" ; "" )
Output: 2¶3¶4

 

Comments

eos   eos, Teg
May 11, 2015
Is that different from what FilterValues() does?
 
Hal Gumbert   Hal Gumbert, Orlando, FL
May 11, 2015
It seems to have the same result!
 
eos   eos, Teg
May 11, 2015
Indeed … :-) And just for kicks:

// ValuesIntersection ( listToCheck; checkList )

Let ( [

$i = $i + 1 ;

currentValue = GetValue ( listToCheck ; 1 ) ;

remainingToCheck = MiddleValues ( listToCheck ; 2 ; ValueCount ( listToCheck ) - 1 ) ;
remainingToCheck = Left ( remainingToCheck ; Length ( remainingToCheck ) - 1) ;

isMatch = PatternCount ( ¶ & checkList & ¶ ; ¶ & currentValue & ¶ ) ; // where you would use FilterValues() – if it existed … ;-)
$matchCount = $matchCount + isMatch ;
matchValue = Case ( isMatch; Case ( $matchCount > 1 ; ¶ ) & currentValue )

] ;

matchValue & Case ( ValueCount ( remainingToCheck ) ; ValuesIntersection ( remainingToCheck ; checkList ) ; Let ( [ $i = "" ; $matchCount = "" ] ; "" ) )

)
 
Hal Gumbert   Hal Gumbert, Orlando, FL
May 13, 2015
Nice... I like how you removed my unneeded parameter.
 

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: