---
schema_version: "1"
id: ff5b19b4b06eb34152abd985948b35ac0a6c24209711dad583879b3c6f13cef3
title: max()
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-max.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-max.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a21a928eaffef526e17ce4039ec6a87e3bc696d3e92358df9d892bf1d0ab263d
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# max()

Returns the maximum value of a dimension or measure field.

## Example - Find the Largest Opportunity for Each Account

```nolang
q = load "Ops";
q = group q by 'Account_Name';
q = foreach q generate 'Company' as 'Company', max('Amount') as 'Largest Deal';
```

## Example - Find the Last Value in List of Airline Destinations per Origin

For dimensions, `max()` sorts the values alphabetically and the last value is returned.

```nolang
q = load "Airlines";
q = group q by 'origin';
q = foreach q generate 'origin' as 'Origin', max('dest') as 'Max Destination';
```

**See Also**

- [min()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-min.md)
