max and max2 functions in the Factory
The max and max2 functions are intended to retrieve the maximum value of an attribute.
The max function retrieves the maximum value of an attribute, while
The max2 function compares two attributes and retrieves the maximum value between them. (we suggest you not to use this function, it only allows compatibility with processes coming from previous Rulex versions (4 and backwards)
The maximum (max) function only is available also by:
Selecting the column in the Data Manager and finding the maximum in the Info panel (for continuous values only).
Dragging the attribute in the Apply area of the Data Manager’s query panel.
Selecting the function in the Sheets tab of the Data Manager.
Function and parameters Be careful when using these functions, because the parameters written into brackets look the same, as they are two attributes, but it is mandatory to add the 2 to the function if we want to compare two values. max function parameters Parameter Description column It identifies the column to which you want to apply the formula. Multiple attributes can be specified, as long as they are enclosed in double brackets. The column parameter is mandatory. group It allows you to group the results by a certain column. max2 function parameters Parameter Description column1 It identifies the column to which you want to apply the formula. The column1 parameter is mandatory. column2 It identifies the column to which you want to apply the formula. The column2 parameter is mandatory. Example - max The following example uses the Students Performance dataset. Description Screenshot In the example here, we want to fill the max attribute with the maximum of the writing score attribute. We type the following formula: If we want to group our results by their reading score, the formula will be: So the results will be: The maximum writing score value associated with the 72 reading score is 80. The maximum writing score value associated with the 90 reading score is 94. When the column value is a list enclosed in double brackets, the formula considers the single rows of the attributes, so it calculates the maximum considering the chosen attributes in rows. The formula will be: The results can be read as follows: For student in row 1, the maximum value between the writing score and the reading score is 74, which is the writing score. For student in row 2, the maximum value between the writing score and the reading score is 90, the reading score. Example - max2 The following example uses the Students Performance dataset. Description Screenshot In the example here, we want to compare the writing score and the reading score, and we want to retrieve the highest values between them. We write the following formula: The results will be: In row 1, the maximum value between the writing score value (74) and the reading score value (72) is 74. In row 2, the maximum value between the writing score value (88) and the reading score value (90) is 90. and so on. The same operation can be performed with the max function. The max2 function allows compatibility with processes coming from previous Rulex versions.max(column, group)
max2(column1, column2)
max($"writing score")
and the function returns the highest value for the writing score.max($"writing score",$"reading score")
and the function returns the highest value for the writing score, grouped by the reading score.max(($"writing score",$"reading score"))
max2($"writing score",$"reading score")