Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions

Transformation Language Reference

Transformation Language Reference

PERCENTILE

PERCENTILE

Calculates the value that falls at a given percentile in a group of numbers. You can nest only one other aggregate function within PERCENTILE, and the nested function must return a Numeric datatype.
The
Data Integration Service
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.

Syntax

PERCENTILE(
numeric_value
,
percentile
[,
filter_condition
] )
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
numeric_value
Required
Numeric datatype. 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, the
Data Integration Service
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).
If the return value is Decimal with precision greater than 15, you can enable high precision to ensure decimal precision up to 38 digits.

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 ports you define in the transformation, returning one result for each group.
If there is no group by port, PERCENTILE treats all rows as one group, returning one value.

Example

The
Data Integration Service
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
    i
    th 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:
PERCENTILE( SALARY, 75, SALARY > 50000 )
SALARY
125000.0
27900.0
100000.0
NULL
55000.0
9000.0
85000.0
86000.0
48000.0
99000.0
RETURN VALUE:
106250.0

0 COMMENTS

We’d like to hear from you!