FileMaker Custom Function:ListPosition ( ListValues ; SearchValue )
IT Professional Consultants Inc.
Author: Joseph Arzate (9.5.13)
[ListValues] – Expecting a “¶” delimited list of values. List submitted should not begin with MORE than 1 ¶ or the function will be inaccurate.
[SearchValue] – The value being searched upon in the List list provided. Any ¶ found in the SearchValue are removed.
Function Result: Returns a number of the position of the “SearchValue” in the list provided. If the “SearchValue” is found more than 1 time returns a ¶ delimited list of the position in the order it is found in the list. Returns 0 when “SearchValue” not found. This is a recursive function and will stop once the “SearchValue” no longer appears on the list in the order it is submitted.
Any ¶ characters submitted in the ‘SearchValue’ are removed and a provision has been added to remove any leading and trailing ¶ from the ‘ListValues’ if it exists. However, if more than 1 ¶ is submitted at the START of the ‘ListValues’ the CF will be inaccurate. Example: ListPosition( “¶¶Apple¶Grape¶Orange¶Cherry” ; “Orange” ) will result in “4” rather than “3”.
Why this CF Created? Needed an easy way to search and analyze a value in a ¶ delimited list. Can be used with the GetValue function to grab the value from a list. Can also be used to count the number of times a value exists in a list by pairing with FM ValueCount function.
more…FileMaker Custom Function:ListPosition ( ListValues ; SearchValue ).