This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
entitySelection.distinct( )

entitySelection.distinct( ) 


 

entitySelection.distinct ( attributePath {; option} ) -> Result 
Parameter Type   Description
attributePath  Text in Path of attribute whose distinct values you want to get
option  Longint in dk diacritical: diacritical evaluation ("A" # "a" for example)
Result  Collection in Collection with only distinct values

The entitySelection.distinct( ) method returns a collection containing only distinct (different) values from the attributePath in the entity selection.

The returned collection is automatically sorted. Null values are not returned.

In the attributePath parameter, pass the entity attribute whose distinct values you want to get. Only scalar values (text, number, boolean, or date) can be handled. If the attributePath is an object attribute that contains values of different types, they are first grouped by type and sorted afterwards. Types are returned in the following order:

  1. booleans
  2. strings
  3. numbers
  4. dates

By default, a non-diacritical evaluation is performed. If you want the evaluation to be case sensitive or to differentiate accented characters, pass the dk diacritical constant in the option parameter.

An error is returned if:

Example  

You want to get a collection containing a single element per country name:

 C_COLLECTION($countries)
 $countries:=ds.Employee.all().distinct("address.country")



See also 

entitySelection.count( )

 
PROPERTIES 

Product: 4D
Theme: ORDA - EntitySelection

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)