How To filter Not Null vaulue in dt.select

Hi! friends
I’m trying to do filtering in assign using datatable.select.
If there are columns [A] to [D],
I want to include column A as mandatory and bring only non-null rows for [B] or [C] or [D]
(In summary, column A will be searched for with a specific value, and if there is a value in at least one of B, C, and D, it will be retrieved)

“DT.select(”[A] = ‘ABC’ And [B] = IS NOT Null or …“)” I did this, but the filtering doesn’t work well.

How should I use .select?

Hi @testbb

Can you try this

dt.AsEnumerable().Where(function(x) x("A").ToString.Equals("ABC") And (Not IsNothing(x("B")) Or Not IsNothing(x("C")) Or Not IsNothing(x("D")))).CopyToDatatable

cheers

Hi,

Equal operator (=) is not necessary with IS NOT operator. So the expression will be as the following.

dt.Select("[A] = 'ABC' AND [B] IS NOT NULL")

Regards,

Hello Yoichi!
thank you
Can I ask you just one more question?
I want to know if the value “A” exists as a header in the DataTable or not.
What should I do?

Hi,

We can check it using the following expression.

dt.Columns.Contains("A")

Regards,

thank you!

1 Like

Thanks!!!

1 Like

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