<!--
{
  "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/sumQuantity()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKStatistics(im)sumQuantity"
  },
  "title" : "sumQuantity()"
}
-->

# sumQuantity()

Returns the sum of all the samples that match the query.

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

## Return Value

If the [`cumulativeSum`](/documentation/HealthKit/HKStatisticsOptions/cumulativeSum) option was set, this method returns a quantity object containing the sum of all the 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)