KNOWLEDGE BASE

How to Mark Duplicate Rows in Tableau Desktop


Published: 08 Mar 2024
Last Modified Date: 08 Mar 2024

Question

How to add a flag to mark duplicate rows.

Environment

  • Tableau Desktop

Answer

Please see the sample packaged workbook found in the Attachments section of the article to follow along with the following steps.

1. Create a calculation field Accumulated Row to merge string values of previous rows until the current row into one string.
 
IF FIRST()=0 THEN LOOKUP(MIN([Item]),0)
ELSE 
PREVIOUS_VALUE(MIN([Item]))+LOOKUP(MIN([Item]),0)
END

2. Add  Accumulated Row to the Rows shelf and set the table calculation direction as below.

User-added image

3. Create a calculation field Accumulated Row(Exclude current row) to remove the string value of the current row only from Accumulated Row.
LEFT([Accumulated Row],INDEX()-1)


4. Add  Accumulated Row(Exclude current row) to the Rows shelf and set the table calculation direction as below.

User-added image

5. Create a calculation field Dup-Flag to mark the duplication row as "Duplicate Row" .
  
IF CONTAINS([Accumulated Row(Exclude current row)],LOOKUP(MIN([Item]),0)) 
THEN "Duplicate Row"
ELSE ""
END

6. Add the Dup-Flag to the Rows shelf and set the table calculation direction as below.

User-added image

7. Add the same Dup-Flag to Color Marks card to color the row.

User-added image

Check the results.

User-added image

 
Did this article resolve the issue?