LINQ - Filtering out empty rows

Hello Friends,
I want to display non empty/non null rows based on column “country”.
I am getting error as shown in below screenshot,

LINQ :–>

From currentRow In DataTbl
Where Not currentRow(“Country”).ToString.IsNullOrEmpty
Select currentRow

May i know why i am getting this error? and how to resolve this error?

(From d In DataTbl.AsEnumerable
Let chk isNothing(d(“Country”)) OrElse String.IsNullOrEmpty(d(“Country”).toString.Trim)
Where Not chk
Select r = d).CopyToDatatable

Handle empty filter result by:
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

Also have a look here:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

Hi @Neal369

Try this

From currentRow In DataTbl.AsEnumerable
Where Not String.IsNullOrEmpty(currentRow(“Country”).ToString)
Select currentRow

Hope this helps



Alternate Approach:

dt.AsEnumerable.SkipWhile(Function(row) String.IsNullorEmpty(row(“country”).ToString)).CopyToDataTable

Hope this helps,
Best Regards.

1 Like

We keep in Mind:

Col Value Sequence: A, B,C, NullOrEmptyString, E, F
SkipWhile will stop after C and not return E,F

1 Like

This is not working,
Giving below error -


I believe you copied the formula directly and pasted it…the error is becUse of the inverted comma…please remove it and re add it…that would solve the error


1 Like

Always ensure or retype all Double Quotes as it has to be: " sometimes copy paste will cause this issue

1 Like


This works perfect, thank you :slight_smile:

1 Like

Correct, my apologies, thank you

1 Like

Working perfect,
Thank you :slight_smile:

1 Like

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