Hey everybody,
I have a question regarding computations in the data modeller.
In our project, we have a data model that holds a repeated include. The repeated elements have (amongst others) two fields amount and type. We also have a computed field, in which the sum of “amount” for all repeated elements should be shown. The computation for this is: Sum(Items*/Item/Amount).
Is there any way to do a “sum-if” computation and just sum up the elements that have type set to a specific value (e.g. “cost”)?
Thanks for your help! 
Hi Christine,
currently, there is no direct language construct to do a sum-if. There is one in planning stage, but I’m not sure, when it will get life.
But there is a workaround:
You can add a technical field e.g. costamount which is in the repeatable group. You calculate that field to amount if the type is “cost” and 0 for other types. Then summing over all these technical fields you should get the desired result.
If you additionally make the field transient, it should not even occur in the payload.
This feature will come with [A12-10998]<INTERNAL_LINK>.
Update:
This feature has been implemented. Please check the validation language documentation for filter operators (also refered to as Filter operator for restriction of the “*” operator). In this case the computation rule would look like this:
Sum(Items*/Item/Amount Having [Items/Item/type] == "costs")
This can currently be used in the 2021.06, 2022.02 and 2022.06 versions.