Hi,
I am using the LINQ to find total amount in a data table column.
dt.AsEnumerable.Sun(Function(row) Convert.ToDouble(row(“Amount”)))
The amount field is having positive and negative amounts. So I need to add up, meaning negative needs to be converted to positive and find total amount. How can I do this?
Thank you so much,
mkankatala
(Mahesh Kankatala)
July 19, 2024, 4:13am
2
Hi @A_Learner
Do you want to convert the negative values to positive values then calculate the total.
rlgandu
(Rajyalakshmi Gandu)
July 19, 2024, 4:14am
3
@A_Learner
dt.AsEnumerable().Sum(Function(row) Math.Abs(Convert.ToDouble(row("Amount"))))
Anil_G
(Anil Gorthi)
July 19, 2024, 4:15am
4
@A_Learner
Try this
dt.AsEnumerable.Sum(Function(row) Math.Abs(Cdbl(row("Amount").ToString)))
Cheers
1 Like
system
(system)
Closed
July 22, 2024, 4:15am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.