Aggregate Data from a Data Store Entity and Display in a Chart

SAIL Recipes give you an opportunity to explore different interface design patterns. To learn how to directly use SAIL recipes within your interfaces, see Adapt a SAIL Recipe to Work with My Applications.


Aggregate data from a data store entity, specifically the total number of employees in a given department, to display in a pie chart.


This recipe uses an employee data structure and objects created through the Use the Write to Data Store Entity Smart Service Function on an Interface recipe. Make sure that recipes has been built first in order to see data in this recipe. This scenario demonstrates:

  • How to use the report builder to aggregate data from a data store entity and display in a pie chart.

Using the Report Builder


  1. Open the Interface Designer and select Report Builder from the list of templates.
  2. In the Source Constant field, select the EMPLOYEE_ENTITYconstant.
  3. Delete the firstName and lastName columns so that only the department and id columns remain.
  4. Select the Group records by common fields option and select Count for the id column.
  5. Select Pie Chart as the visualization.
  6. In the Chart Labels dropdown, select department.
  7. Click Generate. You should see the following expression in the design pane on the left-hand side:

Let's take a look at the expression to see how it relates to what we configured.

  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: -1,
    sort: a!sortInfo(
      field: "department",
      ascending: true
    local!datasubset: a!queryEntity(
      entity: cons!EMPLOYEE_ENTITY,
      query: a!query(
        aggregation: a!queryAggregation(aggregationColumns: {
          a!queryAggregationColumn(field: "department", isGrouping: true),
          a!queryAggregationColumn(field: "id", aggregationFunction: "COUNT"),
        pagingInfo: local!pagingInfo
      series: {
          items: local!datasubset,
          expression: a!chartSeries(
            label: index(fv!item, "department", null),
            data: index(fv!item, "id", null)

The field selected in the "Chart Labels" configuration determines the labels that are displayed with each pie slice. This is the same as the label configuration in a!chartSeries(). The field selected in the "Chart Data Series" configuration determines the data used to create the pie chart slices. This is the same as the data parameter in a!chartSeries().

Notable implementation details