Can anyone help me to do the subtraction operation in uipath.
i.e I wanna subtract two different column in a excel and write the result in another column.
I am trying like this:
- Reading excel file(DT1).
- Passed the DT1 in for each loop.
- Get row item(Column1)
- Get row item(Column2)
- In an assign activity I am displaying the output like Column3= Column1-Column2
but I am getting an error like in the attachment.
Please someone help me on this
And my workflow looks like:
Thanks for the reply, I tried as you suggested but I am getting an error as in the attachment
Add a condition that if that cell is empty it wont do this activity
Thanks for the response I tried I am getting error like
Please help me out on the same
we can defensive handling empty cell value with following:
Cint(“0” & currentrow(ColNameOrIndex).tostring)
please show us the implementation from this: Column3= Column1-Column2
Credit-Debit.xaml (18.3 KB)
there are severeal things to check and maybe to adopt
crosscheck if name or index is properly used for referencing the column
after opening the xaml we saw:
(maybe an opening issue on quick review)
and do see following when click on Name
give a try on Cint(“0” & Credit.toString) - Cint(“0” & Debit.toString)
- using assign activity for getting row’s col value like below allows us to get more control on what we get as the variable type is set by us and the retrieval statement is done by us:
Just start with these modifications and lets see what you will get on next run
So adopt it if needed
As you said I have checked the index in get row item its correct.
after that what you said I didn’t can you please explain a bit
Cint(“0” & Credit.toString) - Cint(“0” & Debit.toString)
I tried your method but I am getting the error
Credit-Debit.xlsx (14.7 KB)
Please find the excel which I am using to achieve the subtraction.
0-3790 string is not value that can be converted into an int. So your data quality is not on a state that the impementation can run or there is a bug in the implementation that creates this string
we can convert 1,2,3 …100 but not number-number …
Issue occured on this part: Cint(“0” & Credit.toString) - Cint(“0” & Debit.toString), right?
Check the statement on your implementation again
you have to convert that value into integer use Cint function
Defensive 0 Trick was confused by negative values
Credit = CurrentRow(“LCY_AMOUNT”).toString
iCredit = if(isNothing(Credit) OrElse String.IsNullOrEmpty(Credit.ToString), 0, CInt(Credit))
Find some starter help here:
Credit-Debit.xaml (12.6 KB)