# Only keep duplicates in Data Table

**URL:** <https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895>\
**Category:** Help\
**Tags:** datatable, question, system, activities\
**Created:** [December 29, 2019, 2:54pm UTC](https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895 "2019-12-29T14:54:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sami\_Syed](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sami_syed/32/52594_2.png) [@Sami\_Syed](https://forum.uipath.com/u/Sami_Syed)\
**Post date:** [December 29, 2019, 2:54pm UTC](https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895/1 "2019-12-29T14:54:59Z")

</div>

I already know how to remove duplicate rows within a DT using the activity.

However, how do we do the opposite?  
Where we keep only duplicated rows and delete all rows that do not have a duplicate?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [December 29, 2019, 3:12pm UTC](https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895/2 "2019-12-29T15:12:36Z")

</div>

Kindly have a view on this thread

> [@How to get duplicate rows?](https://forum.uipath.com/t/how-to-get-duplicate-rows/23661):
>
> Hi, I want to know how can i get the duplicate rows in excel and paste them to some other excel sheet?? Thanks in advance.

Cheers @Sami_Syed

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [December 29, 2019, 4:16pm UTC](https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895/3 "2019-12-29T16:16:05Z")

</div>

@Sami_Syed  
Alternate to the Join approach with a group by the duplicates can be detected as well

In general there are some Options/variations

- Retrieve the duplicates rows within linq Statement
- Retrieve the duplicates rows Key Info and use IT later for retrieval

A very important Info is about the duplicates:

- Identified by all columns?
- Identified by specific column(s)?

In Case of you are interrested on one of the approaches Let US know.

---

<div class="post-metadata">

**Author:** ![Sami\_Syed](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sami_syed/32/52594_2.png) [@Sami\_Syed](https://forum.uipath.com/u/Sami_Syed)\
**Post date:** [December 30, 2019, 3:36pm UTC](https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895/4 "2019-12-30T15:36:37Z")

</div>

I dont understand any of the code on that solution. Could you explain it please?

---

<div class="post-metadata">

**Author:** ![Ashwini\_Kumaran](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashwini_kumaran/32/65066_2.png) [@Ashwini\_Kumaran](https://forum.uipath.com/u/Ashwini_Kumaran)\
**Post date:** [May 13, 2020, 2:58pm UTC](https://forum.uipath.com/t/only-keep-duplicates-in-data-table/180895/5 "2020-05-13T14:58:42Z")

</div>

I would like to retrieve the duplicate rows comparing all columns in one data table? Any inputs
