Table of Contents

Search

  1. Preface
  2. Function reference
  3. Constants
  4. Operators
  5. Dates
  6. Functions
  7. System variables
  8. Datatype reference

Function Reference

Function Reference

MEDIAN

MEDIAN

Returns the median of all values in a selected field.
If there is an even number of values in the field, the median is the average of the middle two values when all values are placed ordinally on a number line. If there is an odd number of values in the field, the median is the middle number.
You can nest only one other aggregate function within MEDIAN, and the nested function must return a numeric data type.
You cannot nest aggregate functions in advanced mode.
Data Integration
reads all rows of data to perform the median calculation. The process of reading rows of data to perform the calculation may affect performance. Optionally, you can apply a filter to limit the rows you read to calculate the median.
Use only in
mapping
tasks.

Syntax

MEDIAN(
numeric_value
[,
filter_condition
] )
Argument
Required/
Optional
Description
numeric_value
Required
Numeric data type. Passes the values for which you want to calculate a median. You can enter any valid transformation expression.
filter_condition
Optional
Limits the rows in the search. The filter condition must be a numeric value or evaluate to TRUE, FALSE, or NULL. You can enter any valid transformation expression.

Return Value

Numeric value.
NULL if all values passed to the function are NULL, or if no rows are selected. For example, the filter condition evaluates to FALSE or NULL for all rows.

Nulls

If a value is NULL, MEDIAN ignores the row. However, if all values passed from the field are NULL, MEDIAN returns NULL.

Group By

MEDIAN groups values based on group by fields you define in the transformation, returning one result for each group.
If there is no group by field, MEDIAN treats all rows as one group, returning one value.

Example

To calculate the median salary for all departments, you create an Aggregator transformation grouped by departments with a field specifying the following expression:
MEDIAN( SALARY )
The following expression returns the median value for orders of stabilizing vests:
MEDIAN( SALES, ITEM = 'Stabilizing Vest' )
ITEM
SALES
Flashlight
85
Stabilizing Vest
504
Stabilizing Vest
36
Safety Knife
5
Medium Titanium Knife
150
Tank
NULL
Stabilizing Vest
441
Chisel Point Knife
60
Stabilizing Vest
NULL
Stabilizing Vest
1044
Wrist Band Thermometer
110
RETURN VALUE:
472.5

0 COMMENTS

We’d like to hear from you!