PatternCountValues ( haystack ; needles )
Does a pattern count for multiple values at once, counting the number of times values in the second value list appear in the first value list.
Be the first to rate this function Log in to vote
Richard Dyce - Show more from this author
Dyce & Sons Ltd. http://dyce.com |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
There is one gotcha with this function. For backwards compatibility, I haven't included a UniqueValues ( ) check on the needles value list - which means that duplicate values in needles leads to double counting, i.e. PatternCountValues ( "123¶234¶235" ; "123¶123¶234" ) will give the answer 3. For 16 & 17 users, use:
// PatternCountValues ( haystack ; needles )
Let (
[
searchterms = ValueCount ( needles );
needles = UniqueValues ( needles ) // prevents double counting
];
Case (
haystack = "" ; 0 ;
searchterms = 0 ; 0 ;
searchterms = 1 ; PatternCount( haystack ; needles ) ;
Evaluate(
"patterncount( " &
Quote ( haystack ) & "; \"" &
Substitute (
needles ;
¶ ;
"\" ) + patterncount( " & Quote ( haystack ) & " ; \""
) &
"\" )"
)
)
)
Comments
Fabrice Nordmann, 1-more-thing Jan 27, 2019 |
||
how about: ValueCount ( Filtervalues ( listA ; listB )) |
||
Richard Dyce, Dyce & Sons Ltd. Jan 28, 2019 |
||
Much better ;-) | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.