Aggregate Functions¶
Aggregate functions do two jobs. They query the records of the current transaction type or a sibling. They also query the values held in a field that an Aggregate transform has set to accumulate values.
Concatenate¶
Description
Returns a string that joins the values of an aggregate field, or of a field in the current or a sibling transaction.
Syntax
Arguments
- field
- The field whose values are concatenated.
- transaction
- The transaction to query.
- To query an aggregate field specify "."; otherwise, specify a valid transaction type.
- testField
- Optional. Limits the concatenation to values where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
Samples
To concatenate a field within a child transaction, separating the values with a space, a dash and a space.
To concatenate a field within an aggregate transaction, separating the values with a comma.
To concatenate the description field on the orderLines transaction where the qty field is equal to zero (0).
To concatenate the description field on the orderLines transaction where the reference field is not empty.
To concatenate the description field on the orderLines transaction where the description itself is not empty.
Count¶
Description
Returns the number of records in the current or a sibling transaction.
Syntax
Arguments
- transaction
- Must be either the transaction type of the current record or one of its siblings.
- field
- Optional. The field to count when counting an aggregate field. Omit it when counting child transactions.
- testField
- Optional. Limits the count to values where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
The testOperator values are:
| Operation | Symbolic value | Non-symbolic value | Integer value |
|---|---|---|---|
| Equals | = |
eq |
1 |
| Not Equals | <> |
neq |
2 |
| Less Than | < |
lt |
3 |
| Less Than or Equals | <= |
lte |
4 |
| Greater Than | > |
gt |
5 |
| Greater Than or Equals | >= |
gte |
6 |
Samples
To count the number of records within a child transaction.
To count the qty field within an aggregate transaction.
To count the orderLines transaction where the qty field is equal to zero (0). The second argument is an empty string. You must supply it, but the function does not use it.
To count the orderLines transaction where the reference field is not empty.
To count the orderLines transaction where the description itself is not empty.
To count the values of the reference aggregate field when the record's status field is not CANCELLED. On an aggregate field the test applies once, to the current record, not to each value.
DistinctCount¶
Description
Returns the number of distinct values in the current or a sibling transaction.
Syntax
Arguments
- field
- The field for which the distinct count is maintained.
- Transaction
- Must be either the transaction type of the current record or one of its siblings.
- To query an aggregate field specify "."; otherwise, specify a valid transaction type.
- testField
- Optional. Limits the distinct count to values where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
The testOperator values are:
| Operation | Symbolic value | Non-symbolic value | Integer value |
|---|---|---|---|
| Equals | = |
eq |
1 |
| Not Equals | <> |
neq |
2 |
| Less Than | < |
lt |
3 |
| Less Than or Equals | <= |
lte |
4 |
| Greater Than | > |
gt |
5 |
| Greater Than or Equals | >= |
gte |
6 |
Samples
To find the distinct count of a field within a child transaction.
To find the distinct count of a field within an aggregate transaction.
To find the distinct count of the description field on the orderLines transaction where the qty field is equal to zero (0).
To find the distinct count of the description field on the orderLines transaction where the reference field is not empty.
To find the distinct count of the description field on the orderLines transaction where the description itself is not empty.
To find the distinct count of the reference aggregate field when the record's status field is not CANCELLED. On an aggregate field the test applies once, to the current record, not to each value.
First¶
Description
Returns the first value from either:
- Array
- A value from an array of values.
- Transaction
- A value in the current or a sibling transaction.
Syntax
Arguments
- transactionOrArray
- Either the child transaction id or the array to take the first element from.
- To query an aggregate field specify "."; otherwise, specify a valid transaction type.
- When you pass an array, the function ignores the field, testField, testValue and testOperation arguments.
- field
- The field of the child transaction.
- testField
- Optional. Returns the first value where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
Samples
Returns 'first', the first element of the array.
Returns the first element of the array that the Split function returns.
Returns the description from the first record of the 'lines' transaction.
Returns the first value of the qty aggregate field.
To get the first record's description field on the orderLines transaction where the qty field is equal to zero (0).
Returns the first record's description field on the orderLines transaction where the reference field is not empty.
Returns the first record's description field on the orderLines transaction where the description itself is not empty.
IsIn¶
Description
Returns True or False to show whether a value exists in either:
- Array
- A value from an array of values.
- Transaction
- A value in the current or a sibling transaction.
Syntax
Arguments
- testValue
- The value to compare to.
- transactionOrArray
- Either the child transaction id or the array to search for testValue.
- To query an aggregate field specify "."; otherwise, specify a valid transaction type.
- field
- Optional. The field of the child transaction. The function ignores it when you pass an array, and requires it when you pass a transaction id.
Samples
Returns True, because 2 is a value in the array.
Returns True, because "2" is one of the values Split returns. Split returns strings, and a string never equals a number: IsIn(2, Vals) is False. Split also keeps any spaces. Splitting "0, 2" gives " 2", and " 2" does not match "2".
Indicates if any qty field in the lines transaction has a zero (0) value.
Indicates if any value of the qty aggregate field is zero (0).
Last¶
Description
Returns the last value from either:
- Array
- A value from an array of values.
- Transaction
- A value in the current or a sibling transaction.
Syntax
Arguments
- transactionOrArray
- Either the child transaction id or the array to take the last element from.
- To query an aggregate field specify "."; otherwise, specify a valid transaction type.
- When you pass an array, the function ignores the field, testField, testValue and testOperation arguments.
- field
- The field of the child transaction.
- testField
- Optional. Returns the last value where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
Samples
Returns 'third', the last element of the array.
Returns the last element of the array that the Split function returns.
Returns the description from the last record of the 'lines' transaction.
Returns the last value of the qty aggregate field.
To get the last record's description field on the orderLines transaction where the qty field is equal to zero (0).
Returns the last record's description field on the orderLines transaction where the reference field is not empty.
Returns the last record's description field on the orderLines transaction where the description itself is not empty.
Minimum¶
Description
Returns the minimum value of an aggregate field or of a field in the current or sibling transaction.
Syntax
Arguments
- field
- The field to take the minimum from.
- transaction
- The transaction to query.
- To query the aggregate field specify "."; otherwise, specify a valid transaction type.
- testField
- Optional. Limits the minimum to values where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
The testOperator values are:
| Operation | Symbolic value | Non-symbolic value | Integer value |
|---|---|---|---|
| Equals | = |
eq |
1 |
| Not Equals | <> |
neq |
2 |
| Less Than | < |
lt |
3 |
| Less Than or Equals | <= |
lte |
4 |
| Greater Than | > |
gt |
5 |
| Greater Than or Equals | >= |
gte |
6 |
Samples
To find the minimum of a field within a child transaction.
To find the minimum of a field within an aggregate transaction.
To find the minimum of the qty field on the orderLines transaction where the item field is equal to "ABC-001".
To find the minimum of the unitPrice field on the orderLines transaction where the item field is not equal to "SHIPPING".
To find the minimum of the extendedAmount aggregate field when the record's qty field is greater than 1. On an aggregate field the test applies once, to the current record, not to each value.
Maximum¶
Description
Returns the maximum value of an aggregate field or of a field in the current or sibling transaction.
Syntax
Arguments
- field
- The field to take the maximum from.
- transaction
- The transaction to query.
- To query the aggregate field specify "."; otherwise, specify a valid transaction type.
- testField
- Optional. Limits the maximum to values where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
The testOperator values are:
| Operation | Symbolic value | Non-symbolic value | Integer value |
|---|---|---|---|
| Equals | = |
eq |
1 |
| Not Equals | <> |
neq |
2 |
| Less Than | < |
lt |
3 |
| Less Than or Equals | <= |
lte |
4 |
| Greater Than | > |
gt |
5 |
| Greater Than or Equals | >= |
gte |
6 |
Samples
To find the maximum of a field within a child transaction.
To find the maximum of a field within an aggregate transaction.
To find the maximum of the qty field on the orderLines transaction where the item field is equal to "ABC-001".
To find the maximum of the unitPrice field on the orderLines transaction where the item field is not equal to "SHIPPING".
To find the maximum of the extendedAmount aggregate field when the record's qty field is greater than 0. On an aggregate field the test applies once, to the current record, not to each value.
Sum¶
Description
Returns the sum of the values of an aggregate field or of a field in the current or sibling transaction.
Syntax
Arguments
- field
- The field to sum.
- transaction
- The transaction to query.
- To query the aggregate field specify "."; otherwise, specify a valid transaction type.
- testField
- Optional. Limits the sum to values where testField meets the condition set by testValue and testOperator.
- testValue
- Optional. Used with testField. The value to compare against.
- testOperator
- Optional. Used with testField. The operator that compares testField with testValue.
The testOperator values are:
| Operation | Symbolic value | Non-symbolic value | Integer value |
|---|---|---|---|
| Equals | = |
eq |
1 |
| Not Equals | <> |
neq |
2 |
| Less Than | < |
lt |
3 |
| Less Than or Equals | <= |
lte |
4 |
| Greater Than | > |
gt |
5 |
| Greater Than or Equals | >= |
gte |
6 |
Samples
To find the sum of the LINETOTAL field from OrderDetail transaction:
To sum the extendedAmount aggregate field.
To find the sum of the extendedAmount field on the orderLines transaction where the item field is equal to "SHIPPING".
To find the sum of the qty field on the orderLines transaction where the item field is not equal to "SHIPPING".
To sum the extendedAmount aggregate field when the record's qty field is greater than 0. On an aggregate field the test applies once, to the current record, not to each value.