Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

...

Info

NOTE: Before you remove duplicates from your dataset, you should verify that the data should not contain duplicates at all. If the data structure supports some duplicate elements including key values, you should exercise care in how you identify what constitutes duplicate information.

...

Remove duplicate rows transformation

D s product
rtrue
provides a single transformtransformation, which can remove identical rows from your dataset:

Tip

Tip: If you are attempting to identify if there are duplicate rows, check the row count in your dataset before and after you have added this transformtransformation.

D trans
Typestep
SearchTermRemove duplicate rows

Limitations:

  • This transform transformation is case-sensitive. So, if a column has values Hello and HELLO, the rows containing those values are not considered duplicates and cannot be removed with this transformtransformation.
  • Whitespace and the beginning and ending of values is not ignored.

Before applying the Remove deduplicate transformrows transformation, you should attempt to normalize your data. You can use the following techniques to normalize a few columns of data.

...

Info

NOTE: To preserve the original column values, use the derive transform New formula transformation. The set transform Edit column with formula transformation replaces the original values.

D trans
Typestep
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueTRIM(Item)
SearchTermNew formula

Since the Remove deduplicate transform rows transformation is case-sensitive, you can use the LOWER function to make the case of each entry in a column to be consistent:

...

Deduplicate Rows Based on a Primary Key

 

An easier Another method to deduplicate data might be to delete rows based on one or more columns that you identify as a primary key for the dataset. A primary key is an identifier that uniquely identifies a row of data within a dataset. It can be a single field (column) or a combination of columns. For example, in a datasets of restaurant locations, the primary key can be a combination of RestaurantName, Address, and Zip.

...

  1. If your primary key spans multiple columns, use the merge transform Merge columns transformation to bring the values into a single column:

    D trans
    Typestep
    p01NameColumns
    p01ValueRestaurantName,Address,Zip
    p02NameSeparator
    p02Value'-'
    SearchTermMerge columns

  2. Rename the generated column: PrimaryKey.

  3. Use the following transform transformation to generate a new column, comparing each value in the PrimaryKey column to the previous one:

    D trans
    Typestep
    p01NameFormulas
    p01ValuePREV(PrimaryKey, 1)
    p02NameOrder by
    p02ValuePrimaryKey
    SearchTermWindow

  4. For each row, the value of the new column is the value in the PrimaryKey for the previous row. Now, test if this value is the same as the value in the PrimaryKey column for the current row:

    D trans
    p03ValueIsDupe
    Typestep
    p01NameFormula type
    p01ValueSingle row formula
    p02NameFormula
    p02ValueIF((window==PrimaryKey),true,false)
    p03NameNew column name
    SearchTermNew formula

  5. The new column (IsDupe) contains true for duplicate primary keys. Delete the rows that are duplicates:

    D trans
    Typestep
    DescriptionCondition
    p01Name(IsDupe==true)
    SearchTermDelete rows

  6. Delete any generated columns that are no longer needed.

...

While this form of duplicate data is rarer, you might want to check on the possibility of duplicate data between your columns. To check for duplicate column data, you can use a transform transformation similar to the following:

...