# Distinct Function

**URL:** <https://forum.uipath.com/t/distinct-function/446110>\
**Category:** Studio\
**Tags:** activities-panel, datatable, question, studio, system, activities\
**Created:** [June 7, 2022, 9:15am UTC](https://forum.uipath.com/t/distinct-function/446110 "2022-06-07T09:15:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpa\_22](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rpa_22/32/264651_2.png) [@rpa\_22](https://forum.uipath.com/u/rpa_22)\
**Post date:** [June 7, 2022, 9:15am UTC](https://forum.uipath.com/t/distinct-function/446110/1 "2022-06-07T09:15:08Z")

</div>

Hello everyone !

I am using:

NewDT = MainDT.DefaultView.ToTable(true,“Product”,“Customer”,“Account”,“Location”)

to get these values distinct datatable, but this function remove other columns.  
Is there any other solution which keeps related other columns?

---

<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:** [June 7, 2022, 9:20am UTC](https://forum.uipath.com/t/distinct-function/446110/2 "2022-06-07T09:20:41Z")

</div>

@rpa_22  
Welcome to the forum

give a try at following:

Assign activity:  
LHS: dtDistinct | datatype: DataTable  
RHS:

```auto
(From d in YourDataTableVar.AsEnumerable
Let k=String.Join("_", {"Product","Customer","Account","Location"}.Select(Function (x) d(x).toString.Trim))
Group d by k1 = k into grp=Group
Select r = grp.First()).CopyToDataTable

```

---

<div class="post-metadata">

**Author:** ![rpa\_22](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rpa_22/32/264651_2.png) [@rpa\_22](https://forum.uipath.com/u/rpa_22)\
**Post date:** [June 7, 2022, 9:46am UTC](https://forum.uipath.com/t/distinct-function/446110/3 "2022-06-07T09:46:50Z")

</div>

Thanks for quick reply & solution !

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [June 10, 2022, 9:47am UTC](https://forum.uipath.com/t/distinct-function/446110/4 "2022-06-10T09:47:08Z")

</div>

Closed on June 10, 2022, 9:47am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
