table check duplicates ...

Prev Next

Function Names

table check duplicates, table check duplicates ignore case, table check duplicates ignore blanks, table check duplicates ingore both, table check duplicates selected rows, table check duplicates ignore case selected rows, table check duplicates ignore blanks selected rows, table check duplicates ingore both selected rows

Description

These functions checks the table for duplicate entries in the orientation identifier headers. Contents other than orientation headers will not be checked. Duplication info will be written into dedicated columns specified in the 3rd and 4th parameters. The different function names distinguish between:

  • ... ignore case, e.g. "Data" and "data" are equivalent
  • ... ignore blanks, e.g. "Last name" and "Lastname" are equivalent
  • ... ignore both, e.g. "Zip Code" and "zipcode" are equivalent
  • The function enging selected rows applies duplication check only on the rows where the row selection expression applies.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled
This function provides a table context for partial table specifications with table name and row number for selected function parameters

Parameter count

3-5 (4-6 with ...selected rows)

Parameters

No.TypeDescription
1.
input
string Name of existing table

Opt. 2.
code
expression
:string
Expression to select rows

Applicable to table check duplicates ... selected rows only:
The table context for partial table specifications is available for referencing just the columns easily. Example: [Year]>=2022.
Attention: Comparison operators = and <> (instead of == and !=) may hijack the next function parameters for its own use as additional comparison operands, e.g. a[]=1,3,5. As long this comparison is not made in the last function parameter, then put parentheses around them, e.g. ... , (a[]=1,3,5), ....

2. / 3.
input
table columns Orientation identifier columns

All rows with common contents in the specified columns will be checked for duplicates. Typical use: Unique identifier in a table to check for duplicates.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • 1 or more column number of header names and column numbers may be specified

Opt. 3. / 4.
input
table column Duplicate identifer column

Name of header to identify the matching duplicates. The first set of duplicates is given 0, further sets with 1, 2, etc. The duplicate identifier count corresponds with the ascending alphabetic order of the orientation columns and longer the sequential top-down order of the table.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • At most one header name or column number may be specified
  • The header will be created if it does ot yet exist.
  • Specify an empty set {} to skip this parameter.

Default value: {} (none)
Opt. 4. / 5.
input
table column Duplicate index column

Number of header to note counting index of duplicates. The first row among the duplicates get index = 0, the following ones 1, 2, etc.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • At most one header name or column number may be specified
  • The header will be created if it does ot yet exist.
  • Specify an empty set {} to skip this parameter.

Default value: {} (none)
Opt. 4. / 5.
input
table column Duplicate count column

Name of header to note number of duplicates identified. If for example 3 duplicates have been identified, then the field in the corresponding rows will all be set to 3.

See table columns as function parameters for general ruling for this parameter.
Specific rules apply for this function:

  • At most one header name or column number may be specified
  • The header will be created if it does ot yet exist.
  • No values can be provided by using an empty set {}

Default value: {} (none)

Return value

TypeDescription
numeral Number of duplications identified

0 = All rows are unique according to the specifications provided in the function parameters
>0 = Number of duplications identified
-1 = Error identified.

Examples

  table initialize( names,  // Gender neutral first names
      { { First Name, Last Name, Gender },
        { Pascale,   Baker,       Male   },
        { Philippe,  Tanner,      Female },
        { Philippe,  Tanner,      Male   },
        { Dominique, Miller,      Male   },
        { Gabriel,   Baker,       Female },
        { Nicola,    Nilsson,     Female },
        { Philippe,  Tanner,      Male   },
        { Gabriel,   Baker,       Male   },
        { Nicola,    Nilsson,     Male   } } );


  table check duplicates ignore case( names, {Last Name, First Name}, Identifier, Index, Count );
  table list ( names );

Output

    0 : First Name | Last Name | Gender | Identifier | Index | Count
    1 : Pascale    | Baker     | Male   |            |       |      
    2 : Philippe   | Tanner    | Female | 2          | 0     | 3    
    3 : Philippe   | Tanner    | Male   | 2          | 1     | 3    
    4 : Dominique  | Miller    | Male   |            |       |      
    5 : Gabriel    | Baker     | Female | 0          | 0     | 2    
    6 : Nicola     | Nilsson   | Female | 1          | 0     | 2    
    7 : Philippe   | Tanner    | Male   | 2          | 2     | 3    
    8 : Gabriel    | Baker     | Male   | 0          | 1     | 2    
    9 : Nicola     | Nilsson   | Male   | 1          | 1     | 2    

Try it yourself: Open LIB_Function_table_check_duplicates.b4p in B4P_Examples.zip. Decompress before use.