# Q) Compare Two Datatable

**URL:** <https://forum.uipath.com/t/q-compare-two-datatable/446309>\
**Category:** Activities\
**Tags:** question, system, activities\
**Created:** [June 8, 2022, 12:14am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309 "2022-06-08T00:14:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![9393](https://avatars.discourse-cdn.com/v4/letter/9/74df32/32.png) [@9393](https://forum.uipath.com/u/9393)\
**Post date:** [June 8, 2022, 12:14am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/1 "2022-06-08T00:14:25Z")

</div>

![image](https://global.discourse-cdn.com/uipath/original/4X/b/6/f/b6f54401700f741ca50e695a01344856cfdaae6e.png)

Hello.

Compare two data tables  
I want to extract data that is not the same.

If you know how,  
I ask for your help.

---

<div class="post-metadata">

**Author:** ![liu\_shubin](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/liu_shubin/32/176938_2.png) [@liu\_shubin](https://forum.uipath.com/u/liu_shubin)\
**Post date:** [June 8, 2022, 12:29am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/2 "2022-06-08T00:29:14Z")

</div>

How many columns do you want to compare? Or all the columns?

If you compare two columns only, you can use activity “Join Data Tables” to check the difference and similarity. You may have to compare columns individually if you want to compare the whole datatable.

---

<div class="post-metadata">

**Author:** ![9393](https://avatars.discourse-cdn.com/v4/letter/9/74df32/32.png) [@9393](https://forum.uipath.com/u/9393)\
**Post date:** [June 8, 2022, 12:33am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/3 "2022-06-08T00:33:51Z")

</div>

I’d like to compare all the columns

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [June 8, 2022, 1:30am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/4 "2022-06-08T01:30:06Z")

</div>

Hi,

The following will help you.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/1/2/7121aef138991f43459555c5129d1b906d73ae43.png)

```
arrDr = dt2.AsEnumerable.Except(dt1.AsEnumerable,DataRowComparer.Default).ToArray

```

arrDr is `DataRow[]` type.

Regards,

---

<div class="post-metadata">

**Author:** ![9393](https://avatars.discourse-cdn.com/v4/letter/9/74df32/32.png) [@9393](https://forum.uipath.com/u/9393)\
**Post date:** [June 8, 2022, 2:04am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/5 "2022-06-08T02:04:28Z")

</div>

Thanks,

Let me ask you one more question.

Only values that are not the same  
Is there a way to extract it?

Ex) 3,3,3,4,4,4,5,5,5

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [June 8, 2022, 2:06am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/6 "2022-06-08T02:06:54Z")

</div>

Hi,

> Only values that are not the same  
> Is there a way to extract it?

Can you elaborate?  
Is “3,3,3,4,4,4,5,5,5” expected output?

Regards,

---

<div class="post-metadata">

**Author:** ![9393](https://avatars.discourse-cdn.com/v4/letter/9/74df32/32.png) [@9393](https://forum.uipath.com/u/9393)\
**Post date:** [June 8, 2022, 2:09am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/7 "2022-06-08T02:09:41Z")

</div>

After comparing the two data tables,  
You must find a location for an unequal value.

so  
I want to extract only the values that are not the same, is it possible?

On the Excel screen that I uploaded as an example,  
The price I want is  
I want to extract only the separate values of 3, 3, 4, 4, 5, 5.

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [June 8, 2022, 2:13am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/8 "2022-06-08T02:13:43Z")

</div>

Hi,

How about the following expression?

 ![image](https://global.discourse-cdn.com/uipath/original/4X/6/2/f/62f0d3b7e479ebab075c03245a19d3f4ffd620d6.png)

```
 String.Join(",",dtResult.AsEnumerable.SelectMany(Function(r) r.ItemArray))

```

Regards,

---

<div class="post-metadata">

**Author:** ![9393](https://avatars.discourse-cdn.com/v4/letter/9/74df32/32.png) [@9393](https://forum.uipath.com/u/9393)\
**Post date:** [June 8, 2022, 3:26am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/9 "2022-06-08T03:26:31Z")

</div>

Thank you.

I want to use Uipath freely like you, so what kind of study should I do?

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [June 8, 2022, 3:34am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/10 "2022-06-08T03:34:59Z")

</div>

Hi,

> [@9393](#):
>
> I want to use UiPath freely like you, so what kind of study should I do?

I think it’s better to learn by UiPath Academy, first. However, the above expression is technique of [VB.net](http://VB.net) rather than UiPath. So, next learn [VB.net](http://VB.net) or C# deeper. The following topic might also help you.

> [@\[HowTo\] - First Start with LINQ (VB.Net)](https://forum.uipath.com/t/howto-first-start-with-linq-vb-net/318964):
>
> LINQ is part of the .NET framework and offers capabilities for interacting with data, objects or other sources within a particular syntax. This HowTo introduces on starting with LINQ (Language-Integrated Query). Current Version of this topic is DRAFT and will be finalized / enhanced soon Introduction Typical tasks for implementing parts of an automation project are interacting with e.g. with data in a datatable or items from collections. LINQ can help to implement it into a compact and standa…

Regards,

---

<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 11, 2022, 3:35am UTC](https://forum.uipath.com/t/q-compare-two-datatable/446309/11 "2022-06-11T03:35:44Z")

</div>

Closed on June 11, 2022, 3:35am UTC

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