知識庫

How to Mark Duplicate Rows in Tableau Desktop


發佈時間 : 08 Mar 2024
上次修改日期 : 08 Mar 2024

問題

How to add a flag to mark duplicate rows.

環境

  • Tableau Desktop

答案

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

 
這篇文章是否解決了問題?