min and min2 functions in the Factory

The min and min2 functions are intended to retrieve the minimum value of an attribute.

  • The min function retrieves the minimum value of an attribute, while

  • The min2 function compares two attributes and retrieves the minimum 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 minimum (min) function only is available also by:

  • Selecting the column in the Data Manager and finding the minimum 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

min(column, group)
min2(column1, column2)

Be careful when using these functions, because the parameters written into brackets look the same, as they are two attributes, but it is essential to add the 2 to the function if we want to compare two values.


Min 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’re enclosed in double brackets. The column parameter is mandatory.

group

It allows you to group the results by a certain column.


Min2 function parameters

Parameter

Description

column1

It identifies the column to which you want to apply the formula. The column 1 parameter is mandatory.

column2

It identifies the column to which you want to apply the formula. The column2 parameter is mandatory.


Example - min

The following example uses the Students Performance dataset.

Description

Screenshot

  • In the example here, we want to fill the min attribute with the minimum of the writing score attribute.

  • We type the following formula:
    min($"writing score")
    and the function returns the lowest value for the writing score.

  • If we want to group our results by their reading score, the formula will be:

  • min($"writing score",$"reading score") and the function returns the lowest value for the writing score, grouped by the reading score.

  • So the results will be:

    • The minimum writing score value associated with the 72 reading score is 59.

    • The minimum writing score value associated with the 90 reading score is 82.

When the column value is a list enclosed in double brackets, the formula considers the single rows of the attributes, so it calculates the minimum considering the chosen attributes in rows.

The formula will be: min(($"writing score",$"reading score"))

The results can be read as follows:

  • For the student in row 1, the minimum value between the writing score and the reading score is 72, which is the reading score.

  • In row 2, the minimum value between the writing score and the reading score is 88, which is the writing score.


Example - min2

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 lowest value between them.

  • We write the following formula:
    min2($"writing score",$"reading score")

  • The results are as follows:

    • In row 1, the minimum value between the writing score value (74) and the reading score value (72) is 72.

    • In row 2, the minimum value between the writing score value (88) and the reading score value (90) is 88.

and so on.

The same operation can be performed with the min function.

The min2 function allows compatibility with processes coming from previous Rulex versions.