# If DataTable is empty

**URL:** <https://forum.uipath.com/t/if-datatable-is-empty/705205>\
**Category:** Activities\
**Tags:** datatable, if-condition, question, excel, system, activities\
**Created:** [December 8, 2023, 11:55pm UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205 "2023-12-08T23:55:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenn.cruz](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jenn.cruz](https://forum.uipath.com/u/jenn.cruz)\
**Post date:** [December 8, 2023, 11:55pm UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/1 "2023-12-08T23:55:29Z")

</div>

Hello,

I am pulling data from another spreadsheet and pasting it. I need to accommodate for the off chance that there is no data. My thought was to use the if activity. If there aren’t any rows with data, skip to the next activity, else write range. Any help would be greatly appreciated.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/1/a/31a046c54e0923c236200ef2729190dc3f9d9b1b.png)

---

<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:** [December 9, 2023, 12:29am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/2 "2023-12-09T00:29:33Z")

</div>

Hi,

How about the following expression?

```
JavaAdvFinalDT is Nothing OrElse JavaAdvFinalDT.Rows.Count =0

```

![image](https://global.discourse-cdn.com/uipath/original/4X/b/8/e/b8ee85fb342c19a996277256e8a3884ed069026e.png)

Regards,

---

<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:** [December 9, 2023, 3:22am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/3 "2023-12-09T03:22:38Z")

</div>

@jenn.cruz

If you are already reading data then you can use the below

`IsNothing(JavaAdvFinalDt) OrElse JavaAdvFinalDt.RowCount>0`

Cheers

---

<div class="post-metadata">

**Author:** ![Vinit\_Kawle](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vinit_kawle/32/555060_2.png) [@Vinit\_Kawle](https://forum.uipath.com/u/Vinit_Kawle)\
**Post date:** [December 9, 2023, 4:14am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/4 "2023-12-09T04:14:13Z")

</div>

Hi @jenn.cruz ,

Thanks for reaching out UiPath Community.

In Condition of If you can use “JavaAdvFinalDT.Rows.Count =0” Then “Skip to the next activity”  
Else “Write Range”

Hope this works for you.

Happy Automation,  
@Vinit_Kawle

---

<div class="post-metadata">

**Author:** ![Parvathy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/parvathy/32/484539_2.png) [@Parvathy](https://forum.uipath.com/u/Parvathy)\
**Post date:** [December 9, 2023, 4:20am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/5 "2023-12-09T04:20:33Z")

</div>

Hi @jenn.cruz

Check out this thread. It might help you.

> [@Compare two Data table to get Not Matched Values From Column Name](https://forum.uipath.com/t/compare-two-data-table-to-get-not-matched-values-from-column-name/702034/5):
>
> Hi @Prateek_Gulab_Pathak[BlankProcess7.zip](https://forum.uipath.com/uploads/short-url/AbImi4YNgXUPifgT8z9mvdOg61P.zip) (131.8 KB) Check out this workflow. You will get the required output as per requirement. Hope it helps!!

Regards

---

<div class="post-metadata">

**Author:** ![vrdabberu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrdabberu/32/484365_2.png) [@vrdabberu](https://forum.uipath.com/u/vrdabberu)\
**Post date:** [December 9, 2023, 7:12am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/6 "2023-12-09T07:12:25Z")

</div>

Hi @jenn.cruz

Use he below syntax in if condition

```auto
JavaAdvFinalDT.Rows.Count = 0

```

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

Regards

---

<div class="post-metadata">

**Author:** ![sasi\_poosarla](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sasi\_poosarla](https://forum.uipath.com/u/sasi_poosarla)\
**Post date:** [December 9, 2023, 12:04pm UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/7 "2023-12-09T12:04:55Z")

</div>

@jenn.cruz

if condition:

> JavaAdvFinalDT.Rows.Count = 0

Cheers!!

---

<div class="post-metadata">

**Author:** ![Nguyen\_Van\_Luong1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nguyen_van_luong1/32/442389_2.png) [@Nguyen\_Van\_Luong1](https://forum.uipath.com/u/Nguyen_Van_Luong1)\
**Post date:** [December 10, 2023, 12:30pm UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/8 "2023-12-10T12:30:39Z")

</div>

You can use data.rowcount  
if data.rowcount =0  
regards,

---

<div class="post-metadata">

**Author:** ![jenn.cruz](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jenn.cruz](https://forum.uipath.com/u/jenn.cruz)\
**Post date:** [December 11, 2023, 2:27am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/9 "2023-12-11T02:27:58Z")

</div>

Thank you for this. The JavaAdvFinalDT is pulling from the below row count. I added 2 at the end to accommodate for the Tab title A1 and Column title A2. Should I utilize JavaAdvrowcount.toString\<=2? If I need to remove the 2 from the end of the formula and place it somewhere else in the code, please let me know.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/5/d/4/5d4b5f2227a20994316149fe8b9293f0be3d1bb1.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:** [December 11, 2023, 3:29am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/10 "2023-12-11T03:29:31Z")

</div>

@jenn.cruz

1. You can simplify the above one like below…

`Dt.AsEnumerable.Where(function(x) IsNothing(x("Region")) OrElse String.IsNullOrEmpty(x("Region").ToString.Trim)).Count + 2`

1. Which checking the if condition you can do `advrouwcount-2>0` so that the extra 2 added can be ignored

Cheers

---

<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:** [December 14, 2023, 3:30am UTC](https://forum.uipath.com/t/if-datatable-is-empty/705205/11 "2023-12-14T03:30:18Z")

</div>

Closed on December 14, 2023, 3:30am UTC

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