Error: Input string was not in correct format

Facing issue while converting to decimal from string.

Used- ‘accSys’ as ‘String’ to store the values from the excel.
‘accSys1_Sum’ as ‘decimal’ or ‘double’.
accSys1_Sum = accSys1_Sum+Convert.ToDecimal(accSys.Replace(" “,”"))

Can anyone help me regarding this?

Thanks and Regards

Hi @AryanSingh

Welcome to uipath community
–what is the value of accSys and
–make sure that you have a default value for accSys1_Sum as 0
–what is replaced here in accSys
Kindly share this detail buddy
this can be resolved
Cheers @AryanSingh

Hey @AryanSingh,

Welcome to the UiPath community!!

accSys.Replace(" “,”") your replace seems incorrect to me.

What are you trying to replace here the syntax for replace should go like this:

accSys.replace(“old value”,“new value”)

–what is the value of accSys :- row(“Example”).ToString
–make sure that you have a default value for accSys1_Sum as 0 : it has
–what is replaced here in accSys :- this one resolved

Just to confirm one thing, if the column name in “row(“Example”).ToString” has spaces between the words. Then, should it be in square brackets


1 Like

accSys.Replace(" “,”")

that typing mistake. sry for that.

no buddy not necesssary, we are mentioning it as string, within double quotes
so no need of square brackets
Fine what is the value of row(“Example”).ToString
only then we can get to know why this error has occurred and this occurred because the input pass is not right format buddy
kindly let know what is replaced as well
if we are using this replace empty space that lies either in front or back of the string we can simply use Trim method like this
accSys1_Sum = accSys1_Sum+Convert.ToDecimal(accSys.ToString.Trim)
where accSys1_Sum should be type Decimal or Double or atleast a int32
Cheers @AryanSingh

Hey @AryanSingh,

No that is only required in case of datatable select filter but if you are getting the row inside the foreach row then there is no need to add the brackets there.

ok thanx.


accSys=row(“Invoice Excl Vat Amt”).ToString
This is the value

Nothing is getting replaced. Wrong command from my side.
So removed the “.Replace”.

what is the value here buddy
row(“Invoice Excl Vat Amt”) will be having some value in the table right
what is that value
Cheers @AryanSingh

Invoice Excl Vat Amt

Values like this.


this will work all except -1291.81
because it has a - in front and thats what showing error
to rectify this
use a if condition like this before assigning value to the accSys1_Sum
like this in if condition
row(“Invoice Excl Vat Amt”).ToString.Contains("-")
if this gets satisfied it will go to THEN part where we have mention the assign activity like this
accSys1_Sum = accSys1_Sum-Convert.ToDecimal(accSys.ToString.Replace("-",""))
or this not getting satisfied it will go to ELSE part where we can mention the assign activity like this
accSys1_Sum = accSys1_Sum+Convert.ToDecimal(accSys.ToString.Trim)

Cheers @AryanSingh

@Palaniyappan Thank you
This is the condition for the if activity.

ConsolidatedDT.Select("[Account Name] = ‘xyz’ and [Bill Account Name] = ‘xyz (PTY) LTD’").CopyToDataTable().ToString=ConsolidatedDT.Select("[Account Name] = ‘xyz’ and [Bill Account Name] = ‘xyz (PTY) LTD’").CopyToDataTable().ToString

Is this command correct?

why this equal to buddy
what is the validation made here
are we tryng to use select method and copy the filtered data made by select method, back to the ConsolidatedDT
if so it should be mentioned like this in assign activity buddy
ConsolidatedDT = ConsolidatedDT.Select("[Account Name] = ‘xyz’ and [Bill Account Name] = ‘xyz (PTY) LTD’").CopyToDataTable()

Cheers @AryanSingh

actually trying to temporarily filter one column and then apply one more filter in other column [like a sub category] and then getting the sum of the subcategory invoice. Bulk of data to filter.

if i save the filtered data in the dataTable then wud be too many datatables.

Should i keep the main DataTable seperate and manipulate the dataTable seperately for each case using for invoke.


For that first filter that data and assign the filtered data back to the same table as mentioned here

And try to sum the value of the subcategory invoice by passing the above datatable variable as input to the for each row loop
–inside the loop use a assign activity like this
out_sum_value = out_sum_value + Convert.ToDecimal(row(“yoursubcategoryinvoicecolumnname”).ToString)

where out_sum_value is a variable of type decimal with default value of 0 defined in te variable panel

Cheers @AryanSingh

Hi @Palaniyappan

I tried the above command but was getting an error like below. Please guide. What type of command modification is required to correct it?

Please check!

This one Error resolved!!!

1 Like

Fine use another datatable varaible on left side not the same
That was my fault, typo mistake
create a variable named FinalDt of type datatable and put the default value as new System.Data.Datatable
Cheers @AryanSingh

after this modification


Fine can i have a view on the value in the right side of the assign activity if possible
there is a constant used under the name ACCSYS
is any such used in the value in the right side
Cheers @AryanSingh

This is the command i am using.