---
schema_version: "1"
id: 7cfeef103f2b69fa815097132d89bc59f52d1c3159fd5149918ad543eb4d34ea
title: percentile_disc()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-fn-agg-pd.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-pd.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f97cca304b223c49f256d1e4a1e4346c89930e65e09e31988619bf0df671d91c
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# percentile_disc()

Returns the value corresponding to the specified percentile.

```nolang
percentile_disc(p) within group (order by expr [asc | desc])
```

`percentile_disc()` accepts a numeric grouped expression _expr_ and sorts it in the specified order. If order is not specified, the default order is ascending. It returns the value behind which (100\*_p_)% of values in the group fall in the sorted order, ignoring null values.

_p_ can be any real numeric value between 0 and 1, and is accurate to 8 decimal places of precision. _expr_ can be any identifier, such as 'xInt' or 'price', but cannot be a complex expression, such as price/100 or ceil(distance), or a literal, such as 2.5.

If _expr_ contains no value that falls exactly at the 100\*p-th percentile mark, `percentile_disc()` returns the next value from _expr_ in the sort order.

For example, if `Mea1` contains the values [54, 35, 15, 15, 76, 87, 78] then:

```nolang
percentile_disc(0.5) within group (order by Mea1) == 54
percentile_disc(0.72) within group (order by Mea1) == 78
```

## Example - Rank Your Reps by Top Quartile of Deal Size

Suppose that you want to see which reps close the biggest deals. (The result may be different than the sum of deal amount, if some reps close a lot of smaller deals). You also want the chart to display the size of actual deals, not an average of deal size. Use `percentile_disc(.25)` to look at the top quarter of the deal size for each rep.

```nolang
q = load "DTC_Opportunity_SAMPLE";
q = group q by 'Account_Owner';
q = foreach q generate 'Account_Owner' as 'Account_Owner', percentile_disc(0.25) within group (order by 'Amount' desc) as 'Amount';
q = order q by 'Amount' desc;

```

You can see that 25% of Julie Chavez's deals are bigger than $2.4 million, and 25% of Kelly Frazier's deals are bigger than $2.2 million. You also know that Julie closed a deal worth\$2.4 million, and that number isn't an average.

![Diagram showing percentile continuous.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_fn_agg_perd.png)

**See Also**

- [percentile_cont()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-pc.md)
- [Show the Top and Bottom Quartile](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-examples-topbotquartile.md)
