I have a variable that contains currency as below, and if I want to create a new variable that contains the total of the existing variables, what is the code?
Is there Separate variables for all the amounts?
And if it has one how is it storing all the amounts Please share screenshot?
- Create one int32 variable of Transaction_amount_Total with Setting Default value to 0.
2.Inside for each loop use assign activity Transaction_amount_Total=Transaction_Amount_Total+cdbl(mappingRow2(“Transaction Amount”).ToString)
Hope it helps.
Regards,
Saloni
oke let me try
Add System.Globalization to the imports (imports panel next to the Variable Panel)
Assign activity
LHS: totalTA | Int32
RHS:
(From d in YourDataTableVar.AsEnumerable
Let ci = New System.Globalization.CultureInfo("de-DE")
Let a = d("Transaction Amount").toString.Trim
Where int32.TryParse( a ,NumberStyles.Any, new CultureInfo("de-DE"), nothing )
Select v = int32.Parse(a,NumberStyles.Any,ci)).Sum(Function (x) x)
feel free to adopt the culture info and the datatype (e.g. shift to Double)
In case of trouble, same techniques for analyzing can be applied as similiar is described here for date time conversion issues
thx for your answer,
umm what mean of RHS and LHS? and what activity used in studio?
@Ridwan_Satrio1 I think there is misplaced characters in amount means instead of 4.680.000,00 it should be like 4,680,000.00 Right?
but the excel input file given in this case is like that. So, I’m having a hard time finding out how to add up the rows, what’s more, there’s a (-) sign in one of the numbers
as several options were suggested, which one did you tried and what was working or not working.
About the differen local number format following approach should work
umm im so sorry but i dont understand what mean of ci, a, d, v and “de-DE” and x in RHS
Create a variable:
Use an assign activity done as here
And replace YourDataTableVar with the variable name of you datatable
it is using LINQ within the statement, we do use these like local variables
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum
OR
As also mentioned you can implement it within a for each row approach and parsing the string into an integer was mentioned here:
start analysis by using a single assign activity. Bring it out from the muliple assign.
set a breakpoint on the failling assign activity
debug and get paused
open immediate panel and type in:
dt_jurnal.Rows(0)(“Transaction Amount”).toString
we want to check the value within the datatable
Maybe the sum exceeds the maximum value of an int32 and we will change the datatype. But lets check out first the result from analysis above