max
This function is used by Ignition's Expression language.
Description
Finds and returns the maximum value in the given column of the given dataset, or the max value in a series of numbers specified as arguments. When looking up the max in a dataset, the column may be specified as an index or as a column name.
This function expects the datatype of the column to be numeric: other datatypes, such as strings, will throw an exception.
Any null values in the column are ignored. If there are no rows in the dataset, null is returned.
Syntax
max(dataset, columnIndex)
Parameters
DataSet dataset - The dataset to search through.
int columnIndex - The index of the column to search through. Must be a column index of the provided dataset. Additionally, the datatype of the column must be numeric.
Returns
- int - The maximum value in that column.
Syntax
max(dataset, columnName)
Parameters
DataSet dataset - The dataset to search through.
string columnName - The name of the column to search through. Must match a column name in the provided dataset. Additionally, the datatype of the column must be numeric.
Returns
- int - The maximum value in that column.
Syntax
max(value[, value...])
Parameters
- int/float value - A number. Can be as many values as needed. Can be either a float or an integer.
Returns
- int - The maximum value in the list of values.
Examples
For example, suppose you had a table with this dataset in it:
ProductCode | Quantity | Weight |
---|---|---|
BAN_002 | 380 | 3.243 |
BAN_010 | 120 | 9.928 |
APL_000 | 125 | 1.287 |
FWL_220 | 322 | 7.889 |
max({Root Container.Table.data}, 1) //would return 380
max(0, 10/2, 3.14) //would return 5. You can also use this function to find the maximum in fixed series of numbers, specified as arguments
max({SomeValue}, 0) //The following example is a great way to make sure a value never goes below zero: