Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

ValuePosition ( valuelist ; searchvalue )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.2  (30 votes)
  Discuss this Custom Function

Michael Bijnens, freelance developer
/

Get position number of the search value from the value list

Sample Input:
ValuePosition (
a¶b¶c¶d¶e¶f" ;
"d"
)
Sample Output:
4


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

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

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

This is my Custom Function and I want to edit it

Discuss:

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 )

Oliver, Tegernsee
June 03, 2014 5:11am

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.

Michael Bijnens, Belgium
June 04, 2014 12:49am

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.

Oliver, Tegernsee
June 04, 2014 2:36am

// 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
)
)

Late to the party, Shanghai
January 08, 2016 2:29am

valuePosition ( "AB¶BC¶CD","B" ) returns an out-of-memory error due to runaway recursion.

Michael Kupietz, United States
November 18, 2017 7:10pm

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 2 + 9 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. NumberToHexadecimal(NumberValue)
  (Fri, Dec 08, 8:54am)
2. Get_BaseTable
  (Thu, Dec 07, 4:27pm)
3. JSONCreateVarsFromKeys ( json ; namespace )
  (Wed, Dec 06, 8:21pm)
4. GetTableNzme ( field )
  (Tue, Dec 05, 9:16pm)
5. TimeFormatAsText ( theTime )
  (Mon, Nov 13, 1:59pm)
6. ParseWebValueList( text )
  (Thu, Nov 02, 9:52am)
7. SVG_HTML_to_Text ( _svg_text ; _orig_text ;
  (Wed, Oct 25, 4:17am)
8. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)

RSS Feed of Custom Functions