Median ( )

Function stats

Average user rating
37
293
9999
Support
FileMaker 8.0 +
Date posted
20 January 2011
Version
1
Recursive function
No

Author Info
 Fabrice

70 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

Median  ( _sortedList )


Parameters

_sortedList  


Description

Tags:  summary   math   array   aggregate  

Simple calculation to calculate the median based on a sorted array (list)
This function does NOT include a sort algorithm. Choose the one you want upfront (value list, custom function, sorted relationship...) and pass the result to this function.

Examples

Sample input

Median ( 1¶2¶3¶4¶5 )
Median ( 1¶2¶3¶4¶5¶6 )


Sample output

3
3.5

 

Function code

/*
Median ( _sortedList )

by Fabrice Nordmann, 1-more-thing
http://www.1-more-thing.com

Simple calculation to calculate the median based on a sorted array (list)
This function does NOT include a sort algorithm. Choose the one you want upfront (value list, custom function, sorted relationship...) and pass the result to this function.

v.1 - Jan 2011

compatibility : FileMaker 8

*/


Case ( IsEmpty ( _sortedList ) ; "" ;
Let ([
    _c = ValueCount ( _sortedList ) ;
    _r = Case ( Mod ( _c ; 2 ) ; GetValue ( _sortedList ; Ceiling ( _c / 2 )) ; ( GetValue ( _sortedList ; _c / 2 ) + GetValue ( _sortedList ; ( _c / 2 ) + 1 ) ) / 2 )
];
_r )
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/293

    Prototype: Median( _sortedList )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 20 January 2011
    Version: 1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (31)
Date  (26)
List  (25)
Format  (23)
XML  (22)
Sql  (18)
Dev  (17)
Debug  (14)
Text  (13)
Variables  (12)
Interface  (12)
Layout  (11)
Filter  (10)
Design  (9)
Array  (7)
Layout Objects  (7)