Calculate Values from Grouped Data
Putting data into groups to calculate aggregated values allows you to extract more information from your data sets. In OutSystems, you can use aggregate functions to calculate values based on groups of identical data.
Fetch the data in an aggregate and do the following:
- In the attribute with identical data, use the
menu and select Group by <attribute>.
- In the attribute to calculate, use the
menu and select an aggregate function such as Count.
Once you group or use aggregate functions on attributes, those attributes become the only output of the aggregate.
Example
In the GoOutWeb application to find, review, and rate places, you want to show the average rating of places to help to take a decision. Consider that you already have an Aggregate fetching all the reviews of a place from the database. Open the aggregate and do the following:
-
On the
Place.Id
attribute, open themenu and choose Group By Id.
-
On the
Review.Rate
attribute, open themenu and choose Average.
-
Use the calculated values to display the average rating for each place on the screen.