How I can check if a column is having any value in any row?

I have a Data table and I want to check if a column for example Column 3 is having any value in any row.

My data table. I want to check if column 3 have some value or not.

I tried filtering but it’s not returing reliable output.

@anneebeek,

You can try this expression in the Assign activity and it will return you true or false.

yourdatatablevariable.AsEnumerable().Any(Function(row) Not String.IsNullOrWhiteSpace(row("Column 3").ToString()))
1 Like

to check all rows for a particular column (defensive approach)

Assign Activity
hasValue | DataType Boolean =

(From d In yourDataTableVar.AsEnumerable
Where Not isNothing(d("YourColName"))
Where Not String.IsNullOrEmpty(d("YourColName").toString.trim))
Select r=d).Any()
1 Like

@anneebeek
feel free to have a closer look at LINQ, that was used for the solution approach

1 Like

Using a for each row
1.Add a Boolean variable:hasvalue-> default False
2.Fro Each Row in Datatable: YourDataTable
3.Inside the loop, use an If activity:

Not String.IsNullOrWhiteSpace(row (3).ToString.trim)

4.If True, set has Value=True and use a Break activity to exit early.

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