I have two separate lists of type list, listActual and listBudget. I need to subtract listBudget from listActual (listActual - listBudget) and store this in a third list. Please help me out with step by step detailed method on how to achieve this.
Create three variables of type List(Of T) for listActual, listBudget, and listResult, where βTβ is the data type of your lists.
Initialize listActual and listBudget with their respective data.
Use the Assign activity to perform the subtraction using LINQ and store the result in listResult. Hereβs how you can do it:
listActual.Zip(listBudget, Function(a, b) a - b).ToList()
This LINQ query uses the Zip method to combine the elements of both lists and then applies a lambda function to subtract corresponding elements, producing the listResult.
After the Assign activity, you can use the listResult variable in UiPath as needed.Preformatted text
=> Initialize the values in the listBudget and listActual.
=> Insert assign activity and create a variable Count which in integer datatype and initialize it as 0.
- Assign β Count = 0
=> Iterate the one list called listActual by using the for each activity.
=> Insert the assign activity inside the for each and create a variable output as double.
- Assign β output = listActual(Count)-listBudget(Count)
=> After this use append collection activity to append the value to the thirdlist which means finallist.
=> After append collection activity insert the assign activity to increment the Count.
- Assign β Count = Count+1
Use an assign statement with left side as resultantList and right side as Enumerable.Range(0, list1.Count).ToDictionary(function(i) i,Function(i) Cint(list1(i))-Cint(list2(i))).Values.ToList