I’m using since a while a LINQ formula that I found here on the forum to sum up all the values in a column of a data table.
The formula is:
math.Round(ML_FilteredDT.AsEnumerable.Sum(Function(a)Convert.ToDouble(a(“ColumnName”).ToString)),2)
The formula was always working, now, suddendly, I’m receiving the error message that “the input string is not in a correct format”, but I changed nothing in the data table…
Please I need help, because the automation is already in production and I need to fix this asap…
math.Round(ML_FilteredDT.AsEnumerable().Where(Function(d) Not String.IsNullOrEmpty(d("columname").ToString) or Not String.IsNullOrWhiteSpace(d("columname").ToString)).Sum(Function(a)Convert.ToDouble(a("ColumnName").ToString)),2)
Thank you this is the solution! The data table is coming from an Excel file and the column is the result of formulas that put empty strings when no values are available…
I’m using for testing and older version of the file. Now I forced them to replace the empty string with 0… But your formula will be really helpful in the future.