# 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()](/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-min.md)
