Remove Duplicates in Tableau

Recently, while I was creating a report on sales data in Tableau, I noticed that a few records were repeated and being counted multiple times. Due to this, the totals in the reports were also calculated with these duplicate values.

As a solution for this, I came to know that in Tableau, there are various methods through which we can remove duplicates, such as formatting the data source details and using calculated fields.

In this Tableau tutorial, I will explain the various methods to remove duplicates in Tableau.

Remove Duplicate Values in Tableau

In Tableau, there are the following methods through which we can remove duplicate values.

  • Remove Duplicates from the data source in Tableau
  • Use LOD Expression to remove duplicate values in Tableau
  • Use the COUNTD() function for unique counts excluding duplicates
  • Aggregate data to avoid displaying duplicate records

Remove Duplicates from the Data Source in Tableau

In this method, we will edit the records in the data source file, which can be an Excel or Google Sheet. This method is helpful when you want to remove duplicates from data before connecting Tableau to the dataset.

  1. Open the data source file in Excel format.
  2. Select all rows -> Go to Data -> Remove Duplicates icon.
Remove duplicate in Tableau
  1. Select the checkboxes for the Columns from which you want to find and delete the duplicates. After selecting the Columns, click OK.
Remove duplicate values in Tableau
  1. As we click OK, the duplicate records will be removed from the data sheet.
Unique count to remove duplicate values

Now, we can connect and use the data in Tableau for data visualisation.

This way, we can remove the duplicates directly from the data source and use the file later in Tableau.

Use LOD Expression to Remove Duplicate Values in Tableau

If duplicates cannot be removed in the source due to permissions, we can use Level of Detail (LOD) expressions to remove them inside Tableau.

For example, we have multiple transactions per customer, but we want to count each customer only once.

Now, follow the steps below to remove the duplicate in the Tableau data source using the LOD expression.

  1. To create a calculated field, click on the Analysis tab and select Create Calculated Field.
  1. Enter the formula below in the calculated field to count the distinct values (avoiding duplicates).
{ FIXED [Customer ID] : MIN([Customer Name])}
  1. Now, to create the view, add the Customer Name and c