Free cookie consent management tool by TermsFeed

a!aggregationFields() Function

On This Page

Function

a!aggregationFields( groupings, measures )

Used to define a query against record data that performs an aggregation in a!queryRecordType(). Uses a!grouping() and a!measure() to define aggregate fields.

Parameters

Keyword Type Description

groupings

Any Type

Fields to group by using a list of a!grouping().

measures

Any Type

Calculations to perform using a list of a!measure().

Returns

Aggregation Fields

Usage considerations

Supported use case

This configuration should always be used within the fields parameter of a!queryRecordType() to define the fields returned when aggregating data.

Using the grouping and measure parameters

  • a!grouping() and a!measure() must be used to define the groupings and calculations.
  • You can provide both groupings and measures, or you can choose to include only measures or groupings.
  • For each grouping or measure provided, the alias is required.

Examples

Record type references are specific to each environment. If you copy and paste these examples into your interface, they will not evaluate. Use them as a reference only.

Use a!grouping and a!measure

This expression returns the three customers with the most orders. To return this value, a grouping and a measure is included in the a!aggregationFields() function.

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
a!queryRecordType(
  recordType: recordType!RE Customer,
  fields: a!aggregationFields(
    groupings: {
    /* Group by customer name */
      a!grouping(
        field: recordType!RE Customer.fields.displayName,
        alias: "customer"
      )
    },
    measures: {
    /* Count orders for each customer */
      a!measure(
        field: recordType!RE Customer.relationships.order.fields.id,
        function: "COUNT",
        alias: "orderCount"
      )
    }
  ),
  pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 3,
    sort: {
      /* Use the measure alias to sort by the count of orders */
      a!sortInfo(
        field: "orderCount",
        ascending: false
      )
    }
  )
).data

The expression returns the following:

1
2
3
4
5
6
7
8
9
10
List of Map - 3 items
  Map
    customer: "Pearle Dybald" (Text)
    orderCount: 26 (Number (Integer))
  Map
    customer: "Cazzie Paoli" (Text)
    orderCount: 24 (Number (Integer))
  Map
    customer: "Sandro Jarley" (Text)
    orderCount: 24 (Number (Integer))

Use a!measure only

This expression returns the total number of orders in the RE Order record type. To return this value, only a measure is included in the a!aggregationFields() function.

1
2
3
4
5
6
7
8
9
10
11
12
13
a!queryRecordType(
  recordType: recordType!RE Order,
  fields: a!aggregationFields(
    measures: {
      a!measure(
        field: recordTypeRE Order.fields.id,
        function: "COUNT",
        alias: "orderCount"
      )
    }
  ),
  pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
).data

The expression returns the following:

1
2
3
List of Map - 1 item
  Map
    orderCount: 4748 (Number (Integer))

Use a!grouping only

This expression returns the month and year when employees in the AT Employee record type started. To return this value, only a grouping is included in the a!aggregationFields() function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
a!queryRecordType(
  recordType: recordType!AT Employee,
  fields: a!aggregationFields(
  /* Only include a grouping  */
    groupings: a!grouping(
      field: recordType!AT Employee.fields.startDate,
      alias: "startDate",
      interval: "MONTH_TEXT"
    )
  ),
  pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 10,
  /* Use the grouping alias to sort by the start date */
    sort: a!sortInfo(field: "startDate", ascending: false)
  )
).data

The expression returns the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
List of Map - 10 items
  Map
    startDate: "January 2026" (Text)
  Map
    startDate: "March 2025" (Text)
  Map
    startDate: "September 2024" (Text)
  Map
    startDate: "August 2024" (Text)
  Map
    startDate: "February 2024" (Text)
  Map
    startDate: "November 2023" (Text)
  Map
    startDate: "September 2023" (Text)
  Map
    startDate: "July 2023" (Text)
  Map
    startDate: "April 2023" (Text)
  Map
    startDate: "February 2023" (Text)

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Compatible
Offline Interfaces Compatible
Sync-Time Custom Record Fields Incompatible
Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Partially compatible

If autoscale is enabled, can be used to configure a supported process event node (such as a start event or timer event).

Process Autoscaling Compatible

Can be used in autoscaled processes.

Event Consumer Filter Conditions Incompatible

Cannot be used in filter conditions.

Event Consumer Event Handlers Incompatible

Cannot be used in event handler expressions.

Feedback