# Remove duplicate rows in powerpivot



## Myura (Jul 8, 2016)

When I create a relationship between two tables, it says each column has duplicate entries. How can I delete them? I just have to check my primary key column and remove rows of duplicate entries.

Thanks in advance


----------



## Matt Allington (Jul 8, 2016)

All relationships in Power Pivot are of the type 1 to many.  Imagine you had a table of sales data in Excel, and the table of sales data had product code and qty.  But you wanted to know product name and quantity.  You could write a VLOOKUP to go to another table, a table with product code and product name to fetch the product name.  But what would happen if you table had 2 different names for the same product code?  everything would fall apart.  When you write a vlookup, you must point to a table that has a primary key (eg product code) and each entry in your sales table (product key) must match only one record in your product table.  Otherwise which value will be returned?  This is how it also works in Power Pivot


----------



## Myura (Jul 8, 2016)

Matt Allington said:


> All relationships in Power Pivot are of the type 1 to many. Imagine you had a table of sales data in Excel, and the table of sales data had product code and qty. But you wanted to know product name and quantity. You could write a VLOOKUP to go to another table, a table with product code and product name to fetch the product name. But what would happen if you table had 2 different names for the same product code? everything would fall apart. When you write a vlookup, you must point to a table that has a primary key (eg product code) and each entry in your sales table (product key) must match only one record in your product table. Otherwise which value will be returned? This is how it also works in Power Pivot



Exactly, my second table has duplicate entries. I want to delete them. I do not know how to do it


----------



## Matt Allington (Jul 8, 2016)

If you load the data via Power Query, there is a "remove duplicates" menu option.  Just select the key column and then click this button.  It will be random as to which row it keeps though.


----------

