Need to remove the same positive and negative value in datatable

I Need to remove the same positive and negative value in datatable

Example
Datatable

Input:
Type. Value

A. 3662.42
B. -205.53

C. 205.53

D. -1245.39

E. 1245.39
F. -3622.42
G. 3622.42

H. 70.42

Here remove the same positive and negative value

Output:

Type. Value

A. 3622.42
H. 70.42

Another example

Input

Type. Value

A. -125

B. 125

C. 345

D. 546

E. 345

Output:

Type. Value

C. 345
D. 546

E. 345

Note: positive and negative value will occur not only first two rows can also occur in middle ,first negative y will be there it’s corresponding positive value will be on next row

Hi,

How about the following sample?

arrDR = dt.AsEnumerable.Where(Function(r) CDbl(r("Value").ToString)*(-1)=CDbl(dt.Rows(i).Item("Value").ToString)).ToArray

Sample20221101-1a.zip (3.4 KB)

Regards,

Hello!

I liked your problem and i tried to solve it.

I’m attaching my code here, see if it helps you.

In general the process will read the row and lookup to a opposite value, if it founds a value, the process will remove both values. If the process doesnt find any value the index is incremented.
RemoveNegativesPositives.zip (58.5 KB)

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