Skip to main content




Service Studio version:

Create a Calculated Attribute in an Aggregate

  • Edit
    Collaborate with us
    Edit this page on GitHub
  • There are situations when the data fetched from the database isn't enough and you need to add more information to each record, namely based on the values returned. OutSystems allows you to do it. You can add new attributes to the records returned by the aggregate based on the value of the other attributes:

    1. In the aggregate, click New Attribute to add a new attribute to the aggregate and name it.
    2. Open the attribute menu and select Edit formula...
    3. Define the expression to calculate the value.


    GoOutWeb, a Web App to check interesting places, has a screen to list places.

    In this screen, you want to address the following requirement: the end user can filter the listed places by category, by selecting an available category from a Combo Box. In each entry of the Combo Box the app displays the number of places that have that specific category along to the category name.

    Create a Calculated Attribute in an Aggregate

    To calculate this data and add it to each entry of the Combo Box do the following:

    1. Since this is a Web App, add an Aggregate to the screen's preparation.

    2. Add the Place entity to it.

    3. In the aggregate, do the following:

      1. Group by Category.Id.

      2. Count by Place.Id to have the number of places per each category.

      3. Group by Category.Label to get the label of each category.

      4. Open the last grouped column menu and add a new attribute. Name it Combo Box Label.

      5. Assign the following expression to the created column:

        If ( Label <> "", Label + " (" + Count + ")" , "Not categorized" + " (" + Count + ")" )

        Label and Count variables are two of the previously grouped columns.

      Create a Calculated Attribute in an Aggregate

    4. Go to the screen and add a Combo Box. Set its values to be the returning list of the new Aggregate.