I have a list in which I am storing invoices, I want a running total to be submitted to another list. So for instance List B
Oranges - 5
Oranges - 10
Cherry's - 5
Cherry's - 2
Oranges - 3
I want the sum to get updated to List A so
Oranges = 18
Cherry's = 7
I have looked at the other documentation located here Adding all values that correspond with an employee in one list, then updating a single item with tha... however I am missing something as I cannot get it to work. If anyone can provide assistance it would be greatly appreciated.
Can you please explain what part is problematic? The thread you link actually describes the general approach quite well so we need to know where exactly you are stuck.
1. For summing up values of a collection you use a "for each" action. You configure it to run for each item of your collection and store the collection item of each run in a separate variable. Inside the for each loop you can use a "Math operation" action. First you create a new variable called "sum". Then you configure the math operation like ["sum" + current collection item] and store the result in "sum" again. At the end of the loop the "sum" variable should store the sum of all items in your collection.
2. Yes, this is an "update item" action. When you query List B, you will first query for the fruit types and store all available in a collection. You then loop throguh the fruit types collection and query List B again for the hours of each fruit type but now you know what fruit type you are running on at the moment and can use this information as a filter to update list A. And you do the update of List A in the fruit types loop and not in the hours loop.
I admit it's a little abstract, but I'm sure you'll get this to work.
Does it matter that I'm using lookups on the list? I.e. the Fruit is the lookup? Also you said "You configure it to run for each item of your collection and store the collection item of each run in a seperate variable" should this variable be the "Sum" that is then used in the math operation?
I have a order status in the system now, so on the form selection it’s using a lookup of fruit types from List A
I have four lines in List B all same fruit quantity is 5300, 2650, 10600, 5300. I am getting a calculation of 15900 as my total in List A is this because it’s pulling out duplicate values? Or not seeing all of the lines? Thoughts?
Your almost there. The issue now is that you're using the FinalQuantity variable as both your running total that you are summing up and the result in your for each. Every iteration of the loop is overwriting your FinalQuantity variable with the next item in the collection and so you only ever have 2 values being added at any time. Create a new variable for either the For Each result or your Math operation result and you should be good to go