Home : Products : Hach WIMS : Hach WIMS Client : Documentation : Function Reference : Math Toolbox Functions : Advanced Functions : GETMED
Q10971 - INFO: GETMED
GETMED returns the median value of a specified expression over the specified period of time. GETMED is an Advanced Math Toolbox Function.

SYNTAX:

GETMED(Exp, DateRange, optional TimeIncrement, optional Number of Values)
where :
Exp is any valid WIMS Expression
DateRange is an expression in one of two forms:

1. StartDate TO EndDate

StartDate is a date literal.  If StartDate is NoDate, then the function does not calculate and returns the value BLANK.

EndDate is a date literal.  If EndDate is NoDate, then the function does not calculate and returns the value BLANK.

2. TimeRangeLiteral

A TimeRangeLiteral Defines start and end dates for a time interval specified.  For a listing of available literals, refer to the TimeRange Literal List.

TimeIncrement is an optional parameter that specifies the time frame of the calculation. Default is BYDAY (Daily).  For a listing of available literals, refer to the TimeIncrement Literal List.

Number of Values is an optional parameter that specifies the maximum number of values to process in the date range (default is 0).  If the value is zero, then the function uses all the real values in the date range.  If the number is 5, for example, then the function will only process the first five values in the date range.  If the number of values requested are not found within the date range, then the function returns BLANK.

NOTES:

The Advanced Math Toolbox Functions give full flexibility to WIMS users to create new calculations that are not currently available with the existing, predefined functions.  Since these functions are very general and very powerful, they do not have a lot of safety checks built into them and must be used with caution.  The advanced functions will generally be slightly less efficient than the predefined functions and are not therefore intended to replace the predefined functions.

The main feature of the advanced functions is the ability to specify the date range for the calculations explicitly in the function call.  This allows nonstandard time frames to be used for summation, averaging, geometric means, etc. The functions also allow calculations within the function call and thus are no longer limited to just working on a single variable.  (i.e., you can now take the sum of C2 * C3)

The range of the advanced functions can be specified in two ways:

  1. By explicit dates (i.e., sum all values from the beginning of the month to the end of the month.) See Date Literals for more information on specifying dates.
  2. By maximum number of values within a date range (i.e., sum the first 5 numbers from the start date to the end date)  These range specifications apply to most of the custom functions.

EXAMPLE:

Example 1: Find the median value of the last X values.

GETMED(C5, TodayIf(D = #MM/LL) TO D - 365, 25)

C5 : get the median of variable 5
TodayIf(D=#MM/LL) : from the current day being calculated, if that day is the last day of the month
TO D - 365 :  to 365 days ago (search one year back)
25 : Take the median of the last 25 values

Example 2: Find an x-day moving median.

GETMED(C5, D-9 TO D)

C5 : get the median of variable 5
D-9 : from 9 days before the current day being calculated
TO D : up to the current day

Example with MDL Rules:

V = GETMED(V5261, D-3 TO D)

On calculated variables, it is possible to elect to cascade MDL rules or not. Below is an example of cascading MOST frequent MDL symbol, ALL MDL symbols, and NONE or no MDL symbols. This also shows an even number of data points and getting a moving median value with MDL symbols.

V9641 - Most Frequent MDL Symbol
V9642 - All MDL Symbols
V9643 - No MDL Symbols

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 4/23/2008 11:01 AM.
Last Modified on 4/1/2014 9:08 AM.
Last Modified by Scott Dorner.
Skill Level: Advanced.
Article has been viewed 2663 times.
Rated 6 out of 10 based on 6 votes.
Print Article
Email Article