# Matching an array and data table

**URL:** <https://forum.uipath.com/t/matching-an-array-and-data-table/416682>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [April 20, 2022, 8:47pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682 "2022-04-20T20:47:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![RPA\_Path](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@RPA\_Path](https://forum.uipath.com/u/RPA_Path)\
**Post date:** [April 20, 2022, 8:47pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/1 "2022-04-20T20:47:10Z")

</div>

Hi everyone,

I have an array and data table consists of dates. I want to check if the dates that are in the data table match with the array. Then, it prints “arrayDate=Tabledate” therefore, it matches. Else, it prints the dates do not match

---

<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:** [April 20, 2022, 9:02pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/2 "2022-04-20T21:02:03Z")

</div>

getting the datatable column value into an array we can do

arrDataDates =

```auto
YourDataTableVar.AsEnumerable.Select(Function (x) x(YourColNameOrIndex).toString.Trim).toArray

```

so with the in your other topic mentioned Set Operation options we can check for the present/absent values

when implementing your case within a for each row we can do:  
For each row in datatable

- IF: arrDate.Contains(row(YourColNameOrIndex).toString.Trim)
  - then: do actions for the matcher
  - else: do actions for the non matchers

![grafik](https://global.discourse-cdn.com/uipath/original/4X/2/3/0/230934ac4efe17e4e31fa397730645a059314755.png)

---

<div class="post-metadata">

**Author:** ![RPA\_Path](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@RPA\_Path](https://forum.uipath.com/u/RPA_Path)\
**Post date:** [April 21, 2022, 2:12am UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/3 "2022-04-21T02:12:43Z")

</div>

I am using Dt.AsEnumerable.Select(Function (x) x(Dt.Rows(“Date”).toString.Trim).toArray). However, I am getting implicit conversions from string to integer error

---

<div class="post-metadata">

**Author:** ![Nithinkrishna](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nithinkrishna/32/561519_2.png) [@Nithinkrishna](https://forum.uipath.com/u/Nithinkrishna)\
**Post date:** [April 21, 2022, 2:22am UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/4 "2022-04-21T02:22:37Z")

</div>

Hey @RPA_Path

Kindly try the below,

```auto
Foreach Row in DataTable

   If dateArr.Contains(Row("Date").ToString.Trim)

         Print "Match"

   Else 

         Print "No Match"

```

Hope this helps.

Thanks  
#nK

---

<div class="post-metadata">

**Author:** ![lakshman](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/lakshman/32/523490_2.png) [@lakshman](https://forum.uipath.com/u/lakshman)\
**Post date:** [April 21, 2022, 3:01am UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/5 "2022-04-21T03:01:25Z")

</div>

@RPA_Path

> [@RPA\_Path](#):
>
> I am using Dt.AsEnumerable.Select(Function (x) x(Dt.Rows(“Date”).toString.Trim).toArray). However, I am getting implicit conversions from string to integer error

Above expression is wrong. It should be like below.

`Dt.AsEnumerable.Select(Function (x) x("Date").toString.Trim).toArray`

---

<div class="post-metadata">

**Author:** ![lakshman](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/lakshman/32/523490_2.png) [@lakshman](https://forum.uipath.com/u/lakshman)\
**Post date:** [April 21, 2022, 4:02pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/8 "2022-04-21T16:02:14Z")

</div>

@RPA_Path

Here you are trying to loop one by one item from DataTable and checking against the array. If the value match then it will go to the **Then** part else **Else** part.

---

<div class="post-metadata">

**Author:** ![RPA\_Path](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@RPA\_Path](https://forum.uipath.com/u/RPA_Path)\
**Post date:** [April 21, 2022, 4:06pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/9 "2022-04-21T16:06:25Z")

</div>

I see where it went wrong, thank you.

---

<div class="post-metadata">

**Author:** ![RPA\_Path](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@RPA\_Path](https://forum.uipath.com/u/RPA_Path)\
**Post date:** [April 21, 2022, 4:22pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/10 "2022-04-21T16:22:57Z")

</div>

One more question, is it possible to log the dates that were matched instead of the word “match”?

---

<div class="post-metadata">

**Author:** ![lakshman](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/lakshman/32/523490_2.png) [@lakshman](https://forum.uipath.com/u/lakshman)\
**Post date:** [April 21, 2022, 4:43pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/11 "2022-04-21T16:43:26Z")

</div>

@RPA_Path

> [@RPA\_Path](#):
>
> is it possible to log the dates that were matched instead of the word “match”?

Yes you can. Write below expression in Log Message activity.

```
         row("Date").ToString.Trim

```

---

<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:** [April 24, 2022, 5:19pm UTC](https://forum.uipath.com/t/matching-an-array-and-data-table/416682/13 "2022-04-24T17:19:22Z")

</div>

Closed on April 24, 2022, 5:19pm UTC

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