COUNTDUPLICATES

COUNTDUPLICATES(array, include_first_instance, ignore_blanks)[source]

Counts the number of duplicate elements in an array according to configurable rules.

COUNTDUPLICATES evaluates an array and returns the total count of duplicates. The behaviour can be customised using include_first_instance and ignore_blanks.

Parameters:
  • array (Operand) –

    The array to check for duplicates. Must be a valid array type or object array.

    Supported types:

    • BOOLEAN_ARRAY

    • INTEGER_ARRAY

    • DECIMAL_ARRAY

    • STRING_ARRAY

    • DATE_ARRAY

    • TIME_ARRAY

    • DATETIME_ARRAY

    • OBJECT_ARRAY

  • include_first_instance (Operand | bool) –

    Determines whether the first occurrence of each duplicate should be included in the count. If True, first occurrence and duplicates are counted; if False, only subsequent duplicates are counted

    Supported types:

    • BOOLEAN

  • ignore_blanks (Operand | bool) –

    Determines whether blank values (null or empty strings) should be ignored in duplicate

    counting.

    Supported types:

    • BOOLEAN

Return type:

Formula

Returns:

A formula object evaluating to an INTEGER representing the count of duplicate elements according to the specified rules.

Supported types:

  • INTEGER

Raises:
  • ValueError – If array is not an array type

  • ValueError – If include_first_instance or ignore_blanks is not BOOLEAN

Examples

Counting duplicates including the first instance:

COUNTDUPLICATES(
    ["A", "B", "A", "C"],
    include_first_instance=True,
    ignore_blanks=False
)
# Returns 2
# Explanation:
# - "A" occurs twice → both counted
# - "B" and "C" occur once → not duplicates

Counting duplicates excluding the first instance and ignoring blanks:

COUNTDUPLICATES(
    ["A", "", "A"],
    include_first_instance=False,
    ignore_blanks=True
)
# Returns 1
# Explanation:
# - "A" occurs twice → only the second counted
# - Blank ignored