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  (29 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

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 + 3 =
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. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions