Calculates the value that falls at a given percentile in a group of numbers.
Data Integration reads all rows of data to perform the percentile calculation. The process of reading rows to perform the calculation may affect performance. Optionally, you can apply a filter to limit the rows you read to calculate the percentile.
You can nest only one other aggregate function within PERCENTILE, and the nested function must return a numeric data type. You cannot nest aggregate functions in advanced mode.
Numeric data type. Passes the values for which you want to calculate a percentile. You can enter any valid transformation expression.
percentile
Required
Integer between 0 and 100, inclusive. Passes the percentile you want to calculate. You can enter any valid transformation expression. If you pass a number outside the 0 to 100 range, Data Integration displays an error and does not write the row.
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, PERCENTILE ignores the row. However, if all values in a group are NULL, PERCENTILE returns NULL.
Group By
PERCENTILE 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, PERCENTILE treats all rows as one group, returning one value.
Example
Data Integration calculates a percentile using the following logic:
Use the following guidelines for this equation:
•x is the number of elements in the group of values for which you are calculating a percentile.
•If i < 1, PERCENTILE returns the value of the first element in the list.
•If i is an integer value, PERCENTILE returns the value of the ith element in the list.
•Otherwise PERCENTILE returns the value of n:
The following expression returns the salary that falls at the 75th percentile of salaries greater than $50,000: