how to write linq query to filter out from compare column which has values of $0.00 and $0.01 from the data table
i want data excluding $0.00 and $0.01
how to write linq query to filter out from compare column which has values of $0.00 and $0.01 from the data table
i want data excluding $0.00 and $0.01
Hi @T_Y_Raju
Try this
filteredDataTable = dataTable.AsEnumerable().Where(Function(row) Not (row.Field(Of String)("CompareColumn") = "$0.00" Or row.Field(Of String)("CompareColumn") = "$0.01")).CopyToDataTable()
Regards,
of filed should string or double because the values are like $.0.00,$0.01,$12,345.78
Since the values include currency formatting ($0.00, $0.01, $12,345.78), they should be treated as strings when filtering.
Regards,
but iam getting error as unable to cast object of type system.Decimal to type system.String
getting error as option strict disallows operands of type Object for operator =
Try the below syntax
DT.AsEnumerable().Where(Function(row) Not (row("Taxes").ToString.Trim.Equals("0") or row("Taxes").ToString.Trim.Contains("0.00") Or row("Taxes").ToString.Trim.Contains("0.01"))).CopyToDataTable()
its not filtering the data
InputFile.xlsx (8.2 KB)
i have attached input file plz remove $0.00 and $0.01 data
Hi @T_Y_Raju ,
Try below expression
Input_DT.AsEnumerable().Where(Function(row) Not (row("Compare").ToString() = "$0.00" Or row("Compare").ToString() = "$0.01")).CopyToDataTable()


Hope it helps you
Regards,
Vinit Mhatre
How about the following?
Code:
Dim rowsToDelete As New List(Of DataRow)
For Each row As DataRow In dtInput.Rows
Dim compareValue As String = row("Compare").ToString().Trim()
If compareValue = "$0.00" Or compareValue = "$0.01" Then
rowsToDelete.Add(row)
End If
Next
For Each row As DataRow In rowsToDelete
dtInput.Rows.Remove(row)
Next
Output:

Cheers!!
Hi @T_Y_Raju
Try this Linq query
ReadDT.AsEnumerable().Where(Function(row) Not (row(“Price”).ToString() = “$0.00” Or row(“Price”).ToString() = “$0.01”)).CopyToDataTable()
Output
Hope it works.
Cheers