KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Determining If Duplicated Values Exist
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: April 24, 2023

Below is an example of using ORDA to quickly determine if a Field of a Table has duplicate values:

$entSelAll:=ds.TableName.all()
$allRecCount_l:=$entSelAll.length
$distinctCount_l:=$entSelAll.FieldName.distinct().length

If($distinctCount_l=$allRecCount_l)
//All values are unique
Else
//There are some duplicate values.
End if

This can be helpful to quickly confirm if there are any duplicate values in a field.

The .countValues() function can then be applied to find which values appear more than once in a loop. Which should only be performed after confirming that there are duplicate values, exspecially with larger tables.