Sum based on two criteria
I am looking for some help/advice on the best way to sum certain data within a list. I have a list of objects, and I want to sum the Receipts based on if the Month and Product matches. I've tried a couple different If statement variations, but I'm not getting what I need. The information used in the flow are coming from 2 separate databases, so I am unable to write a query to obtain this information easily.
Comments
-
Start by using a Create Data step to make a list to hold all the sums of the matches. I have made a list of my ExampleDataStructure called FinalList. Then I pass List1 of my ExampleDataStructure into the first for EachStep and and pass List2 into the second ForEach step.
Be sure to change the outputs of at least one of the ForEach steps so that you can access both items from the ForEach steps in the rest of the steps.
In the Rule Collection Filter step, I have built an array containing both of the items I would like to compare in the rule.
And in the rule, I compare both the months and the product.
In the [Rule] Is Match, I pass in the matches from the Rule Collection Filter step and check if the List is Not Empty. If there isn't a match, the flow will move on to the next items to compare.
If there is a match, I send the both items to an Add step to add the prices together.
Then in another Create Data step, create a new ExampleDataStructure and pass in the month and product from one of the list items and the Total Price computed in the Add step.
Lastly, we will add the new match to our Final List. It is important that the Original List and the New List have the same name!
Howdy, Stranger!
Categories
- 4.1K All Categories
- 61 General
- 11 Training
- 201 Installation / Setup
- 1.1K Flows
- 106 Rules
- 260 Administration
- 212 Portal
- 489 General Q & A
- 693 Forms
- 333 Reports
- 3 Designer Extensions
- 47 Example Flows
- 51 CSS Examples
- 1 Diagram Tile
- 7 Javascript Controls
- 178 Pages
- 5 Process Mining
- New Features
- 178 Datastructures
- 69 Repository
- 219 Integrations
- 28 Multi-Tenant
- 27 SDK
- 76 Modules
- 56 Settings
- 25 Active Directory
- 12 Version 7
- 35 Version 8
- 66 Lunch And Learn Questions