@Max (Formula Language)

Returns the largest number in a single list, or the larger of two numbers or number lists.

Note: The single-parameter form of this @function is new with Release 6.

Syntax

@Max( number1 )

@Max( number1 ; number2 )

Parameters

number1

Number or number list.

number2

Number or number list.

Return value

maxNumber

(Single parameter) Number. The largest number in number1.

(Two parameters) Number or number list. Either number1 or number2, whichever is larger. If the parameters are number lists, @Max returns a list that is the result of pair-wise computation on the list values.

Usage

When using this function with a number list constant, remember that the list concatenation operator takes precedence over other operators. Enclose negative numbers in parentheses.

Examples

  1. This example returns 3.
    @Max(1;3)
  2. This example returns 99;6;7;8.
    @Max(99:2:3;5:6:7:8)
  3. This example returns -2; 45; 54.
    @Max((-2.6):45:(-25);(-2):(-50):54)
  4. This formula finds the larger of the values in the fields named Commission and Salary, and compares the value to 50,000; if it is larger than 50,000, the Bonus field is changed to 0; if it is smaller than 50,000, Bonus becomes 10% of the value in the Salary field.
    FIELD Bonus:=@If(@Max(Commission;Salary)>50000; 0; (0.10 * Salary)); 
  5. This example returns 99.
    @Max(99 : 2 : 3)
  6. This formula compares the corresponding sales figures in the jian_yrtotal and julie_yrtotal fields (which contain number lists) and returns a number list containing the larger of the two figures per element. If there are seven elements in the jian_yrtotal field and five in the julie_yrtotal field, this formula only returns the five largest numbers. Unlike the default behavior, which is to first repeat the fifth element until the list lengths are equal and then compare all seven corresponding elements in the lists, it does not repeat the fifth number in the julie_yrtotal field twice before performing the comparison.
    tjian := @Count(jian_yrtotal);
    tjulie := @Count(julie_yrtotal);
    dif := (tjian - tjulie);
    result := @If(@Sign(dif) = -1;@Subset(julie_yrtotal;(tjulie - @Abs(dif)));
    @Subset(jian_yrtotal;(tjian - dif)));
    result2 := (@If(@Sign(dif) = -1;
    @Max(jian_yrtotal;result);@Max(result;julie_yrtotal));"
    @If(@IsError(result2);"One of your list fields is empty";result2)