Interface patterns give you an opportunity to explore different interface designs. To learn how to directly use patterns within your interfaces, see How to Adapt a Pattern for Your Application.
Aggregate data from a data store entity, specifically the total number of employees for each title in the Engineering department, to display in a bar 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:
EMPLOYEE_ENTITY
constant.firstName
, lastName
, and department
columns so that only the id
column remains.title
and click Add Field.Count
for the id
column.Total
.title
.You should see a chart that looks similar to this:
To add a filter, enter the following expression after the aggregation parameter of a!query()
:
filter: a!queryFilter(field: "department", operator: "=", value: "Engineering"),
The comma at the end of this expression is included because pagingInfo is defined later. Your final expression should look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
load(
local!pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: a!sortInfo(
field: "id",
ascending: true
)
),
with(
local!datasubset: a!queryEntity(
entity: cons!EMPLOYEE_ENTITY,
query: a!query(
aggregation: a!queryAggregation(aggregationColumns: {
a!queryAggregationColumn(field: "id", aggregationFunction: "COUNT"),
a!queryAggregationColumn(field: "title", isGrouping: true),
}),
filter: a!queryFilter(field: "department", operator: "=", value: "Engineering"),
pagingInfo: local!pagingInfo
)
),
a!barChartField(
categories: {
index(local!datasubset.data, "title", null)
},
series: {
a!chartSeries(
label: "id",
data: index(local!datasubset.data, "id", null)
)
}
)
)
)
a!query()
. If you would like to filter using multiple constraints, use a!queryLogicalExpression()
in the logicalExpression parameter instead.