<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKStatistics/averageQuantity()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKStatistics(im)averageQuantity"
  },
  "title" : "averageQuantity()"
}
-->

# averageQuantity()

Returns the average value from all the samples that match the query.

```
func averageQuantity() -> HKQuantity?
```

## Return Value

If the [`discreteAverage`](/documentation/HealthKit/HKStatisticsOptions/discreteAverage) option was set, this method returns a quantity object containing the average value of all samples matching the query; otherwise, it returns `nil`.

## See Also

[`endDate`](/documentation/HealthKit/HKStatistics/endDate)

The end of the time period included in these statistics.

[`startDate`](/documentation/HealthKit/HKStatistics/startDate)

The start of the time period included in these statistics.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)