Calculating total list of attributes

0
Hi all,  In my app I have a Entity1 with two attributes "Date Added" and "Amount Added". I would like to somehow add up all the "Amount Added" from Entity 1 and use the result for a calculated attribute in Entity 2  "AmountToDate". Association: Entity 1 *-1 Entity 2 I've followed part 4 of this post: https://docs.mendix.com/howto/logic-business-rules/working-with-lists-in-a-microflow#4-calculating-a-total-list-value-using-a-variable-and-a-loop I've set up the microflow which has not triggered any errors. However... I need to use two parameters in the microflow because there are two entities. I get an error though when I try to use two parameters. (I presume this is because it's calculating a attribute?) So i'm a bit stuck, Does anyone know a better way of doing it? Or have any suggestions?     EDIT: Thanks Tim, everything is now set up and your solution has got it working with no errors.  Something however is not working properly, please could someone look this over? The attribute value is not changing.   
asked
2 answers
0

Place attribute "AmountToDate" in Entity1, still as calculated field.

The calculation microflow for field "AmountToDate" will sum the amounts for the relevant Entity1-Objects.

There is no data-overhead since calculated fields don't get stored.

 

answered
0

As you have a list of entity 1, performance wise it would be better to use a list operation to aggregate the "AmountAdded" attribute instead of iterating on it in a loop.

As Tim said, as this is a calculated field the attribute will only "change" when the entity is being used somewhere, whether that is in a microflow or showing it on a page.

answered