Shopping Cart

Search:

Signup

Contact

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

# FileMaker Pro Custom Functions

Median ( valueList )

Rate this function:

Average rating: 3.9  (43 votes)
Discuss this Custom Function

Daniele Raybaudi, ACI
www.aci.it

returns median value of a value list

Sample Input:
 0 2 3 5 6 8 9
Sample Output:
 5

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

## Description:

Returns median value of a value list.
ValueList must be sorted in ascending order.

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:

You need to use MiddleValues with this function rather than MiddleWords. MiddleWords removes decimal points for non integer values.

Let ([
count = WordCount ( valueList ) ;
odd = MiddleValues ( valueList ; Truncate (count/2;0) +1 ; 1 );
even = MiddleValues ( valueList ; Truncate(count/2;0) ; 1 )
];
Case(
Mod ( count ; 2 ) ; odd ; (even+ odd) / 2
)
)

David Weaver, Australia
June 30, 2010 8:21pm

Important to note in the description: "ValueList must be sorted in ascending order." I use the revised version that replaces MiddleWords with MiddleValues, and I use one of the other sort functions on this site as the first item in the Let statement to first sort valuelist , so:

Let ([
valuelist = SortValues (valuelist; 1);
count = WordCount ( valueList ) ;
odd = MiddleValues ( valueList ; Truncate (count/2;0) +1 ; 1 );
even = MiddleValues ( valueList ; Truncate(count/2;0) ; 1 )
];
Case(
Mod ( count ; 2 ) ; odd ; (even+ odd) / 2
)
)

Brian Panhuyzen, Toronto
November 24, 2016 11:35am

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 9 + 6 =
 Search for Custom Functions:

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