4D v16.3

Min

Home

 
4D v16.3
Min

Min 


 

Min ( series {; attributePath} ) -> Function result 
Parameter Type   Description
series  Field, Array in Data for which to return the minimum value
attributePath  Text in Path of attribute for which to return the minimum value
Function result  Date, Number in Minimum value in series

Min returns the minimum value in series. If series is an indexed field, the index is used to find the minimum value.

If the series selection is empty, Min returns 0.

You can pass an array (one or two dimensions) in series. In this case, the array must be of the Integer, Longint, Real, or Date type.

This command accepts an optional attributePath parameter of the Text type, that you can use if series is an object field. It allows you to define the path of the attribute to compute. Use the standard dot notation to define paths to nested attributes, for example "company.address.number". Keep in mind that object attribute names are case-sensitive.
Only numeric attribute values are computed. If there are values in the attribute path which are not of a numeric type, they are ignored.

If the command is correctly executed, the OK system variable is set to 1. If it is interrupted (for example if the user clicks on the Stop button of the progress thermometer), the OK variable is set to 0.

The following example is an object method for the variable vMin placed in the break 0 portion of the form. The variable is printed at the end of the report. The object method assigns the minimum value of the field to the variable, which is then printed in the last break of the report:

 vMin:=Min([Employees]Salary)

Note: Make sure the "On printing break" form event is selected for the variable.

The following method is called to print the records in the selection and to activate break processing:

 ALL RECORDS([Employees])
 ORDER BY([Employees];[Employees]Company;>)
 BREAK LEVEL(1)
 ACCUMULATE([Employees]Salary)
 FORM SET OUTPUT([Employees];"PrintForm")
 PRINT SELECTION([Employees])

Note: The parameter to the BREAK LEVEL command should be equal to the number of breaks in your report. For more information about break processing, refer to the chapter Printing.

The following example finds the lowest sale amount of an employee and displays the result in an alert box:

 ALERT("Minimum sale = "+String(Min([Employees]Sales)))

This example gets the lowest value in the array:

 ARRAY REAL($ArrGrades;0)
 QUERY([Exams];[Exams]Exam_Date=!01/07/11!)
 SELECTION TO ARRAY([Exams]Exam_Grade;$ArrGrades)
 vMin:=Min($ArrGrades)

For an example of computing an object field attribute, please refer to the example 3 of the Average command description.



See also 

Max
On a Series

 
PROPERTIES 

Product: 4D
Theme: On a Series
Number: 4

The OK variable is changed by the commandThis command can be run in preemptive processes

 
HISTORY 

New
Modified: 4D v11 SQL Release 3
Modified: 4D v13
Modified: 4D v16

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)