Assign : Input string was not in a correct format.Assign : Input string was not in a correct format

Hello I’m facing a problem:

ListA = (From p In dt3.Select() Group p By ID=p.Item(“Business Unit”).ToString Into GroupA=Group Select Convert.ToString(GroupA.Sum(Function(x) Convert.ToDouble(x.Item(“Amount”).ToString)))).ToList()

1 Like

Please consider we would love to have more info about your data. more info means better help.

Then with the info you give us the problem seems to be that not all your data in de column amount have the correct format. In that case you have to search deeper:

  • Is possible you have null or empty values? - Then you should filter with a Where(function(row) not string.isnullorwhitespace(x.Item(“Amount”).tostring))

  • Is possible you are not using standard numeric format? If this is the problem you can change the format, do some work with split and substring or in case is cultural change (language) just change your cultureInfo before and after.

    1. Assign: 
           Left: system.globalization.cultureinfo.currenculture
           Right: new system.globalization.cultureinfo("YOUR CULTURE") check MSDN
    2. Assign with your formula
    3. Assign: 
           Left: system.globalization.cultureinfo.currenculture
           Right: system.globalization.cultureinfo.invariantculture
    

I wish it helps!

thanks,

I’m trying to do the same work as in:

How do I group by one column in the datatable and take the sum?

The values to be summed are in general:
-732,70
-51,30
-23 040,00
131 333,86
-107 510,00
0,14
-2 514,67
2 514,67
-2 710,00
0,49
35 449,51
-32 740,00
-3 899,00
3 899,19
-0,19
9 049,88
-4 893,74
-4 156,00
-0,14
-990 444,20
-13 539,69

Hi, you have both problems :slight_smile:

  1. You should replace your whitespace x.Item(“Amount”).Replace(" “,”")
  2. You seem to have spanish notation also so… .Replace(“,”,“.”) or use the cultureinfo change i mentioned in my post

please dont hesitate to try and come back to resolve more doubts :slight_smile:

1 Like

thanks,

i had done the samething:

image

the issue still the same, the column i had added is a string one

I will reffer to my previous post:

  1. Assign:
    Left: system.globalization.cultureinfo.currenculture
    Right: new system.globalization.cultureinfo(“YOUR CULTURE”) check MSDN Here your coulture seems to be “ES-es”
  2. Assign with your formula “And also Replace(” “,”“)”
  3. Assign:
    Left: system.globalization.cultureinfo.currenculture
    Right: system.globalization.cultureinfo.invariantculture

Copy and paste that code in assigns and remember to follow the order :slight_smile:

I had done this but still have the error

Hi All
Im getting this error.

Hi @Shiva_Raj

I would try outputting your data first via log message to see what might go wrong. Try with small bits of the code first and then expand your If condition to contain the full expression.

1 Like