Aggregation

Use JSONata aggregation to return the results of values to find a maximum, minimum, or average value in an array.

Configuration

Result
Expression

Maximum

=$max(@ctx.datasources.mydata.array)

Minimum

=$min(@ctx.datasources.mydata.array)

Sum

=$sum(@ctx.datasources.mydata.array)

Examples and code snippets

Aggregated expression
Aggregated expression

In this example static data is agregated in a component.enity to show the result in the entity field.

See the full example code sample in GitHub.

expression.jigx
datasources:
  mydata: 
    type: datasource.static
    options:
      data:
        - name: Jane Stevens
          title: Doctor
          email: [email protected]
          number: 0.64734
          number2: 12
          color: blue
          time: '2021-11-07T15:07:54.972Z'
          array: [5,1,2,3,7,9]

children:
  - type: component.entity
    options:
      children:
        - type: component.entity-field
          options:
            label: Max
            value: =$max(@ctx.datasources.mydata.array)
        - type: component.entity-field
          options:
            label: Min
            value: =$min(@ctx.datasources.mydata.array)
        - type: component.entity-field
          options:
            label: Sum
            value: =$sum(@ctx.datasources.mydata.array)

Last updated

Was this helpful?