Hi Ike,
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.
Regards
Philipp
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
- Query List B for Fruit & Approved store this in a collection “Fruit”
- Remove the Duplicates from the Fruit Collection and Store them in new collection “UniqueFruit”
- Create For Each
- Target Collection “UniqueFruit”
- Store Result in new variable
- Create Variable “TempFruit” Type of Variable is Single Line of Text
- Query List B
- Filter off of Status = Approved
- Filter off of Fruit = TempFruit (Variable)
- Field = Quantity
- Store in “RunningQuantity” (collection)
- Create For Each (Inside of first Create For Each)
- Target Collection “RunningQuantity”
- Create “FinalQuantity” variable (number)
- Store Result in “FinalQuantity”
- Create Math Operation inside second “For Each”
- Workflow Date “FinalQuantity” plus List Lookup Current Item “Quantity” Store Result in “FinalQuantity”
- Outside of the second “For Each” but inside the first “For Each” Update List Item
- Update List A
- Where Fruit equals Value (of list Fruit
- Field selection is Quantity equals Workflow Data “FinalQuantity”
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?
Hi Ike,
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