Collection Functions
Functions for aggregate operations on lists and collections.
Collection Count
Counts the number of items in a collection.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 1 |
| Returns | integer |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list of integer, float, decimal, money | Collection to count |
Example:
Collection Count(LineItems) → number of line items
Collection Count(Participants) → number of participants
Collection Count(Errors) → number of errors found
Collection Sum
Returns the sum of all elements in a numeric collection.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 1 |
| Returns | Highest weight numeric type |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list of integer, float, decimal, money | Collection to sum |
Example:
Collection Sum(LineItemTotals) → order total
Collection Sum(Scores) → total score
Collection Sum(Payments) → total payments received
Collection Average
Returns the average of all elements in a numeric collection.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 1 |
| Returns | Highest weight numeric type |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list of integer, float, decimal, money | Collection to average |
Example:
Collection Average(TestScores) → average score
Collection Average(Ratings) → average rating
Collection Average(ResponseTimes) → average response time
Collection Maximum
Returns the highest value in a collection.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 1 |
| Returns | Highest weight numeric type |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list of integer, float, decimal, money | Collection to search |
Example:
Collection Maximum(Prices) → highest price
Collection Maximum(Bids) → winning bid
Collection Maximum(Temperatures) → peak temperature
Collection Minimum
Returns the lowest value in a collection.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 1 |
| Returns | Highest weight numeric type |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list of integer, float, decimal, money | Collection to search |
Example:
Collection Minimum(Prices) → lowest price
Collection Minimum(StockLevels) → minimum stock level
Collection Minimum(Scores) → lowest score
Projection
Transforms each item in a collection into a new value.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 2 |
| Returns | list (of the selector's result type) |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list | Source collection to project |
| 1 | Selector | any expression | Expression evaluated for each element to produce the new value |
Description: Projects each element of a collection to a new form, returning a new collection of the results (a map/select operation). Each element is exposed to the selector through a configurable element variable, and its position within the collection is available through that element's .Index.
Example:
Projection(LineItems, Multiply(Item.Quantity, Item.UnitPrice)) → collection of line totals
Projection(Contacts, Concatenate(Item.FirstName, " ", Item.LastName)) → collection of full names
Filter
Selects the items in a collection that satisfy a condition.
| Property | Value |
|---|---|
| Category | Collection Utilities |
| Min Arguments | 2 |
| Returns | list (same type as the source collection) |
Arguments:
| # | Name | Type | Description |
|---|---|---|---|
| 0 | Collection | list | Source collection to filter |
| 1 | Condition | boolean | Boolean expression evaluated for each element; elements that evaluate to true are kept |
Description: Filters a collection, returning a new collection containing only the elements for which the condition evaluates to true. Each element is exposed to the condition through a configurable element variable.
Example:
Filter(Orders, Is Greater Than(Item.Amount, 1000)) → orders over 1,000
Filter(Contacts, Not Null Or Empty String(Item.Email)) → contacts that have an email
Collection Functions Quick Reference
| Function | Returns | Use Case |
|---|---|---|
| Collection Count | integer | How many items in the list |
| Collection Sum | numeric | Total of all values |
| Collection Average | numeric | Mean of all values |
| Collection Maximum | numeric | Highest value |
| Collection Minimum | numeric | Lowest value |
| Projection | list | Transform each item into a new value |
| Filter | list | Keep only items that match a condition |
Common Patterns
Order Total Calculation:
Collection Sum(LineItemAmounts)
Checking if Collection Has Items:
Is Greater Than(Collection Count(Items), 0)
// Or simply use: Any(Items)
Average with Minimum Check:
If Condition(
Is Greater Than(Collection Count(Scores), 0),
Collection Average(Scores),
0
)
Range Validation:
And(
Is Greater Than Or Equal To(Collection Minimum(Values), MinAllowed),
Is Less Than Or Equal To(Collection Maximum(Values), MaxAllowed)
)
Statistical Summary:
Format("Count: {0}, Sum: {1}, Avg: {2}, Min: {3}, Max: {4}",
Collection Count(Values),
Collection Sum(Values),
Collection Average(Values),
Collection Minimum(Values),
Collection Maximum(Values)
)