MAX (Numbers)
Returns the maximum numeric value found within a port or group. You can apply a filter to limit the rows in the search. You can nest only one other aggregate function within MAX. You can also use MAX to return the latest date or the highest string value in a port or group.
Syntax
MAX( numeric_value [, filter_condition] )
The following table describes the arguments for this command:
Argument | Required/ Optional | Description |
---|
numeric_value | Required | Numeric datatype. Passes the numeric values for which you want to return a maximum numeric value. You can enter any valid transformation expression. |
filter_condition | Optional | Limits the rows in the search. The filter condition must be a numeric value or evaluate to TRUE, FALSE, or NULL. You can enter any valid transformation expression. |
Return Value
Numeric value.
NULL if all values passed to the function are NULL or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).
Nulls
If a value is NULL, MAX ignores it. However, if all values passed from the port are NULL, MAX returns NULL.
Group By
MAX groups values based on group by ports you define in the transformation, returning one result for each group.
If there is no group by port, MAX treats all rows as one group, returning one value.
Example
The first expression returns the maximum price for flashlights:
MAX( PRICE, ITEM_NAME='Flashlight' )
ITEM_NAME | PRICE |
---|
Flashlight | 10.00 |
Regulator System | 360.00 |
Flashlight | 55.00 |
Diving Hood | 79.00 |
Halogen Flashlight | 162.00 |
Flashlight | 85.00 |
Flashlight | NULL |
RETURN VALUE: 85.00 | |