How to group a list based on one attribute and apply aggregate function on another

Hi Team,

I have a list of records [{ key & value }] pairs and need to sum the value by grouping the key. Is there any Outsystems default action available to do this manipulation on list objects ?



Hi Karthik,

You can do this in either two ways, using aggregates or using SQL queries.



Hi Karthik,

Daniel is quite correct if you are working with a list of entities.

Additionally, if the list is a structure then you will have to perform a for loop and manually add the values.

There is a DynamicLinq component that could do it, but it is probably over engineering your requirement to use this.

It would be possible to create an extension to do this, however it would not be compile safe, as the attribute to sum would be provided as text. Although, not a bad idea for an addition to the MathUtils component.

Based on your question, I have added an Idea to add list operations which will perform sum, average and some other mathematical operations.

I hope this helps.

Kind regards,