Sum the values having currecy symbols in data tables

I have a data table with column(Invoice Amount) having $14,990.00 and $12,349.34.
How to sum these two values.
i tried this.

Invoice.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Invoice Amount”).ToString.Trim) ).ToString

but working only if there is no symbol. how to remove currency symbol to do sum.
Please advice.

@Vishwanth_Raya Have you tried this and Checked if it works :
Invoice.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Invoice Amount”).ToString.Replace("$","").Trim)).ToString

2 Likes

Thank you its working, How to add thousand separator to that?

@Vishwanth_Raya What do you mean by Thousand Separator?

Eg. 14,990.00 like this

@Vishwanth_Raya You can try using the Replace again in this way :
Invoice.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Invoice Amount”).ToString.Replace("$","").Replace(",","").Trim)).ToString

No, i need to add “,” before 990.00. How to achive this dynamically. 14,990

i got it @supermanPunch by using like this
Convert.ToDecimal(14990.00).ToString("#,##0.00")

1 Like

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