# Filter datatable through Invoke code

**URL:** <https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [February 16, 2023, 10:05am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839 "2023-02-16T10:05:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 16, 2023, 10:05am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/1 "2023-02-16T10:05:46Z")

</div>

[RPA - Copy.xlsx](https://forum.uipath.com/uploads/short-url/utNVYbIVgltC9rCKOjwNod80AEc.xlsx) (13.1 KB)  
From Description Column i need TVS & BLANK ROW IN ANOTHER SHEET (FINAL 2)  
" ONLY WITH INVOKE CODE "  
DONE THIS WITH FILTER DATA TABLE AND LINQ

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 17, 2023, 6:09am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/2 "2023-02-17T06:09:45Z")

</div>

@Krishan_Rapswal

Whatever you write in assign for linq…is the same thing that you can copy to your incoke code and run it

Add argument for input and output datatables

Cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 17, 2023, 6:54am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/3 "2023-02-17T06:54:43Z")

</div>

but first i have to filter the data table  
so what i have to do can you please suggest

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 17, 2023, 6:59am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/4 "2023-02-17T06:59:49Z")

</div>

@Krishan_Rapswal

In invoke code use

`Newdt = dt.AsEnumerable.Where(function(x) x("columnname").Tostring.contains("avc")).CopyToDatatable`

This will filter columnname column in the give dt with avc

Hope this helps

Cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 17, 2023, 7:06am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/5 "2023-02-17T07:06:58Z")

</div>

If i want a blank value from that column so i will leave blank in place of avc right?

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 17, 2023, 7:11am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/6 "2023-02-17T07:11:08Z")

</div>

You can use `IsNothing(x("column")) orelse String.IsNullOrEmpty(x("Column").ToString.Trim)`

Cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 17, 2023, 7:25am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/7 "2023-02-17T07:25:51Z")

</div>

" and what if we need 2 data from a column one is blank and another one has value "  
i am sorry i am learning and want to know about all conditions

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 17, 2023, 7:51am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/8 "2023-02-17T07:51:56Z")

</div>

@Krishan_Rapswal

You can include any number of conditions

`(IsNothing(x("column")) orelse String.IsNullOrEmpty(x("Column").ToString.Trim)) AndAlso x("column2").ToString.Contains("acb")`

Cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 17, 2023, 8:46am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/9 "2023-02-17T08:46:23Z")

</div>

[Main filter first.xaml](https://forum.uipath.com/uploads/short-url/e1ZPT6cR4x64KVk3ylhTFsOgXw1.xaml) (8.9 KB)  
[main final.xaml](https://forum.uipath.com/uploads/short-url/lAzMLwuz4V6buVYEA4Uifv6dpOk.xaml) (13.8 KB)  
[RPA - Copy (4).xlsx](https://forum.uipath.com/uploads/short-url/6dPgZjg6KcV9TW9zU1jWjcvaerV.xlsx) (15.3 KB)  
these are my linq data and excel file with result  
when i am using this in Invoke Code the it showing me to many errors

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 17, 2023, 8:47am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/10 "2023-02-17T08:47:25Z")

</div>

![Screenshot (34)](https://global.discourse-cdn.com/uipath/original/4X/c/2/f/c2f31172942cacf6c834528be706f7f0969d4569.png)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 17, 2023, 9:07am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/11 "2023-02-17T09:07:04Z")

</div>

@Krishan_Rapswal

if you are using any variables in the invoke code they have to be passed as arguments using edit arguments else they wont be recognized

please change accordingly

cheers

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [February 17, 2023, 9:11am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/12 "2023-02-17T09:11:02Z")

</div>

HI @Krishan_Rapswal

It says Current Row is not declared whether this invoke code is inside the For each row in datatable if not put into that

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 17, 2023, 9:30am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/13 "2023-02-17T09:30:03Z")

</div>

![Screenshot (35)](https://global.discourse-cdn.com/uipath/original/4X/a/3/0/a30b9976c24510c9bd17bb7de492cc65e2203499.png)  
 ![Screenshot (36)](https://global.discourse-cdn.com/uipath/original/4X/e/0/9/e0987497a94ea2a82b8e661456d542c8a538c53a.png)  
 ![Screenshot (37)](https://global.discourse-cdn.com/uipath/original/4X/6/b/4/6b44144dff672f4e2a019ab835d3f7bbfef29f48.png)  
 ![Screenshot (38)](https://global.discourse-cdn.com/uipath/original/4X/3/c/a/3ca2f06d025f51018b3d8141f4e3f8ac20f63627.png)  
Still getting more error

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 17, 2023, 9:34am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/14 "2023-02-17T09:34:59Z")

</div>

@Krishan_Rapswal

What is currentrow? is the datatype string? I beleive it should be datarow as per the name I see…and the functions you used

please declare the datatypes appropriately and link the variable to the argument to pass the data

Please show the complete code you have in invoke code to see what you are trying to do…Because I do not see any for loop to add currentrow in your invoke code piece

cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 21, 2023, 3:41am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/15 "2023-02-21T03:41:37Z")

</div>

![Screenshot (42)](https://global.discourse-cdn.com/uipath/original/4X/0/5/a/05a3eccd135c73e3e4d676887137249571c78829.png)  
getting this

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 21, 2023, 3:47am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/16 "2023-02-21T03:47:30Z")

</div>

((IsNothing(x(“Description”)) OrElse String.IsNullOrEmpty(x(“Description”).ToString.Trim)) AndAlso x(“Description”).ToString.Contains(“TDS”))  
(CurrentRow.Field(Of Double)(“Amount”)\* -1)  
(CurrentRow.Field(Of Double)(“SIGN”)\* 10)  
(CurrentRow.Field(Of Double)(“PERCENT”) - CurrentRow.Field(Of Double)(“SIGN”))  
(Datediff(DateInterval.Day,DateTime.ParseExact(CurrentRow(1).ToString,{“dd.MM.yyyy hh:mm:ss”,“MM/dd/yyyy hh:mm:ss”,“MM-dd-yyyy”,“dd-MM-yyyy”},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None),now).ToString)

I am using this in invoke code

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 21, 2023, 3:58am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/17 "2023-02-21T03:58:32Z")

</div>

@Krishan_Rapswal

I still dont see any currentrow that you passed or declared as variable or argument…

That is the mistake in the code

Cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 21, 2023, 4:09am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/18 "2023-02-21T04:09:30Z")

</div>

![Screenshot (43)](https://global.discourse-cdn.com/uipath/original/4X/e/a/e/eae91662426112862b168c7bc5295bf528bfe5e1.png)

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 21, 2023, 4:15am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/19 "2023-02-21T04:15:43Z")

</div>

@Krishan_Rapswal

Where is the value to it?

And currentrow.Field is of type string is what you declared in the argument and currentrow.field is the direct name.which is wrong

Cheers

---

<div class="post-metadata">

**Author:** ![Krishan\_Rapswal](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/krishan_rapswal/32/362709_2.png) [@Krishan\_Rapswal](https://forum.uipath.com/u/Krishan_Rapswal)\
**Post date:** [February 21, 2023, 4:30am UTC](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839/20 "2023-02-21T04:30:07Z")

</div>

![Screenshot (48)](https://global.discourse-cdn.com/uipath/original/4X/a/9/7/a97ac83a6cc1e92d711f772e7bf7b596d352d257.png)  
 ![Screenshot (49)](https://global.discourse-cdn.com/uipath/original/4X/d/0/b/d0bf237c088ff05403895cf87d81d54dc032a415.png)

Now getting syntax error

[Next page](https://forum.uipath.com/t/filter-datatable-through-invoke-code/517839.md?page=2)
