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:

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