I have a datatable which I delete the rows where the rows “first quantity” and “second quantity” column values match.
But sometimes the excel is exported faulty and for examle,
first quantity value is 72 and second quantity column value is 72000, but actually this a column I want to delete.
So is there a way I can do something like; if second column quantity value includes first quantity columns value, remove that row from datatable?
Since “72000” includes “72” it could do the job for me.
(Also I cannot use for each row because there are 15000 rows so it takes alot of time)
I need tomething like :
(From d In dtMainData.AsEnumerable
Let k1=d(“first quantity.”).ToString
Let k2=d(“second quantity”).ToString
if k1.contains(k2)(delete row)
Assign activity:
leftSide: dtFiltered (Datatype: Datatable)
right side:
(From d In dtMainData.AsEnumerable
Let k1=d("first quantity").ToString
Let k2=d("second quantity").ToString
Let m = {k1.Length, k2.Length}.Max()
Where Not k1.PadRight(m,"0"c).Equals(k2.PadRight(m,"0"c))
Select d).CopyToDataTable
handling empty filterresult can be done with this pattern:
@jntrk
Edited the LINQ as the Not for filtering out was ommited
can you please rerun the LINQ and check if the created datatable is in match with the expected output.
Thanks
following cases:
“2” → “2.000,00” or “1.4” → “1.400,00”
we will handle in a next iteration
Line1 - iterate over datatable, refer to looped row by d
Line2/3 - memorize the values from first/second qty
Line4 - retrieve the longest lenth from k1,k2
Line5 - filter the rows
Line6 - use the rows, passing the filter for copying to a datatable