#### Maximum

Function

- Maximum(array_variable);
- Maximum(field_variable);
- Maximum(field_variable, groupby);

Description

This function is used to pick up the maximum value from a group of values referred to by the first argument. The groupby argument specifies the group by field name.

Arguments

- field_variable
  field_variable is a special variable in Formula, and refers to a group of values from a database or formula field.
- array_variable
  array_variable refers to an array whose element should be Number.
- groupby
  Groupby can be a constant String to indicate the groupby field name, or a field variable on which grouping occurs, or a parameter variable that can accept a different value before each execution of a report.

Return type

The result type relies on the first argument. It may be Number, Currency, String, Date, Time, DateTime, or Boolean if the datatype of each element in the first argument is Number, Currency, String, Date, Time, DateTime or Boolean respectively.

Examples

- `Number x = Maximum([1.0, 2.0, 3.0, 4.5, 45.0, 67.0])`
- `Number x[6] = [1.0, 2.0, 3.0, 4.5, 45.0, 67.0];
  Number y = Maximum(x)`
- `Number x = Maximum(@dbfield)`
- `Date x = Maximum(@formula)`
- `Time x = Maximum(@dbfield, "group_field")`
- `DateTime x = Maximum(@dbfield, @"group_field")`
- `String x = Maximum(@dbfield, @parameter)`
- `Currency x = Maximum(@dbfield)`
- `Boolean x = Maximum(@formula)`
- `Date x = Maximum(@formula, "group_field")`
- `Currency x = Maximum(@formula, @"group_field")`
- `Currency x = Maximum(@formula, @parameter)`
- `String x = Maximum(['1', '2', '3.0', '4.5', '45', '67'])`
- `Date x = Maximum([toDate(1998, 1, 1), toDate(1997, 7, 1), toDate(1999, 1, 16)])`

Note: If a field_variable is assigned to another variable, for example X, the variable X will lose the characteristic of representing a group of values. The following formula will then be treated as incorrect.

`Number x = @dbfield;
Number y = Maximum(x); // system will prompt you that there is no such kind of function.`