# ValuePosition ( valuelist ; searchvalue )

Get position number of the search value from the value list

 Michael Bijnens freelance developer /

Sample input:
ValuePosition (
a¶b¶c¶d¶e¶f" ;
"d"
)
Sample output:
4

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

This CF gives you the position number of the search value from the given value list ( array separated by ¶ ).

 oliverJun 3, 2014 ValuePosition ( "aÂ¶bÂ¶cÂ¶bÂ¶a" ; "a" ) = 5; and ValuePosition ( "aÂ¶bÂ¶cÂ¶bÂ¶a" ; "bÂ¶c" ) returns empty!? But then it's not necessary to employ a recursive mechanism for finding the index of the first occurrence; simply use ValueCount ( Left ( valuelist ; Position ( valuelist ; searchvalue ; 1 ; 1 ) ) ) btw. â€¦ found = Case ( lastvalue = search ; True ; False ) is the same as found = lastvalue = search and exist = Case ( PatternCount ( list ; search ) = False and not IsEmpty ( search ) ; False ; True ) is simply exist = PatternCount ( list ; search )
 Michael Bijnens, BelgiumJun 4, 2014 Dear Oliver, As you can see my CF name = ValuePosition and not ValuePositionS. So its not made for more multi value searches. Try your simple example with numbers like ( 53 , 353, 121, 12 ). I have tried it in many different ways but it is not waterproof so thats why I use a recursive function.
 oliverJun 4, 2014 Michael wrote: Try your simple example with numbers like ( 53 , 353, 121, 12 ) Michael â€“ you're right, I forgot a little detail; change it to ValueCount ( Left ( valuelist ; Position ( Â¶ & valuelist & Â¶ ; Â¶ & searchvalue & Â¶ ; 1 ; 1 ) ) ) and that'll give you exactly the same functionality without recursion. Also, note that your CF returns the last position, not the first one.
 Late to the party, ShanghaiJan 8, 2016 // I like to use this: /* ValuePosition( _valuelist; _value ) Parameters: _valuelist: a return-delimited string of values; _value: a single-line string. Returns: an integer identifying the listed position of (the first occurrence of) _value within _valuelist, or 0, whenever the _value is not listed. */ If( // return zero when no match occurs: IsEmpty( FilterValues( _valuelist; _value ) ); 0; // FileMaker 15 should provide something like this function for us, but doesn't â€¦ Let( [ // first, bracket the arguments supplied with "Â¶"s: _valuelist = "Â¶"&_valuelist&"Â¶"; _value = "Â¶"&_value&"Â¶"; // locate the "Â¶" character immediately preceding (the first occurrence of) _value: _position = Position( _valuelist; _value; 1; 1 ); // extract all the return characters BEFORE this _position: _returns = Filter( Left( _valuelist; _position ); "Â¶" ); // how many are there? _valuePosition = Length( _returns ) ]; _valuePosition ) )
 Michael Kupietz, Michael Kupietz FileMaker ConsultingNov 18, 2017 valuePosition ( "ABÂ¶BCÂ¶CD","B" ) returns an out-of-memory error due to runaway recursion.

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: