Median ( valueList )
returns median value of a value list
Average rating: 4.0 (40 votes) Log in to vote
Daniele Raybaudi - Show more from this author
ACI http://www.aci.it |
2
3
5
6
8
9
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Returns median value of a value list.
ValueList must be sorted in ascending order.
Comments
David Weaver, Australia Jun 30, 2010 |
||
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 ) ) |
||
Brian Panhuyzen, Neutrino Data Systems Nov 24, 2016 |
||
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 ) ) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.