--- type: "fhirpath-function" title: "FHIRPath Function: aggregate" function: "aggregate" category: "Aggregates" section: "7.1" source: "fhirpath/functions.json" --- # FHIRPath Function: aggregate _No canonical section match found in index.md._ ## Summary - **Category**: Aggregates - **Section**: `7.1` - **Return Type**: `value` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `false` ## Description Performs general-purpose aggregation by evaluating the aggregator expression for each element of the input collection. Within this expression, the standard iteration variables of `$this` and `$index` can be accessed, but also a `$total` aggregation variable. ## Arguments - `aggregator`: `expression` - Expression to evaluate for each element - `init` (optional): `value` - Initial value for the accumulator ## Type Mapping - n/a ## Example ```fhirpath value.aggregate($this + $total, 0) ```