Error : Conversion from string "1.006.869" to type 'Double' is not valid

Hi All, @Gokul001 ,

I am trying to add memory of same user using LINQ query like in below screenshot but It is failing when the value is like “1.006.869”

LINQ query

(From d In dt_ExtractDataTable.AsEnumerable
Group d By k=d(“User ID”).toString.Trim Into grp = Group
Let nj = grp.Sum(Function (x) CDbl(x(“Memory (Net)”).toString.Trim))
Let ra = New Object(){k,grp.First()(1),nj}
Select r = dt_Clone.Rows.Add(ra)).CopyToDataTable

Screenshot of value when facing error

Error Message

Memory Usage Group Assign: Conversion from string “1.006.869” to type ‘Double’ is not valid.

Related question

Hi @Mandava_Naresh

How about this expression

(From d In DtBuild.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Let nj = grp.Sum(Function (x) Double.Parse(x("Value").toString.Trim,System.Globalization.CultureInfo.CreateSpecificCulture("Es-es")))
Let ra = New Object(){k,grp.First()(1),nj}
Select r = DtClone.Rows.Add(ra)).CopyToDataTable

Output

image

1 Like

Check out the XAML file @Mandava_Naresh

GroupBySumBuildDt.xaml (8.9 KB)

Regards
Gokul

Hi @Gokul001 ,

Thanks for responding

12 + 1.006.895 should be something around 13 right ?

But we are getting as “1006907” …The sum value is wrong ?

I have to take this value and check with other value …If this value is wrong then condition will fail.

image

Can you try with main input and check it?

Have you need to write the data in the excel file? If yes, check it with writing the data in the excel file @Mandava_Naresh

@Gokul001 … Not in excel … I have to check whether the value is greater than 2000000 and If yes then I have to perform something in application

Input

Output

image

Values is wrong

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