--- type: "fhirpath-function" title: "FHIRPath Function: toQuantity" function: "toQuantity" category: "Conversion" section: "5.5.7.1" source: "fhirpath/functions.json" --- # FHIRPath Function: toQuantity _No canonical section match found in index.md._ ## Summary - **Category**: Conversion - **Section**: `5.5.7.1` - **Return Type**: `Quantity` - **Empty Input Result**: `empty` - **Errors on Multiple Input**: `true` ## Description If the input collection contains a single item, this function will return a single quantity if the item is an Integer or Decimal, a Quantity, a String convertible to a Quantity, or a Boolean. ## Arguments - `unit` (optional): `String` - Optional unit to convert to ## Type Mapping - `Integer-Quantity` - `Decimal-Quantity` - `Quantity-Quantity` - `String-Quantity` - `Boolean-Quantity` ## Example ```fhirpath q.toQuantity('g') // changes the value and units in the quantity according to UCUM conversion rules ```