---
title: "statistics(for:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkworkoutactivity/statistics(for:)"
---

# statistics(for:)

Returns the activity’s statistics for the provided quantity type.

## Declaration

```swift
func statistics(for quantityType: HKQuantityType) -> HKStatistics?
```

## Parameters

- `quantityType`: The type of doc://com.apple.healthkit/documentation/HealthKit/HKQuantitySample objects used to calculate the statistics.

## Discussion

Discussion HealthKit calculates an HKStatistics object based on the HKQuantitySample objects that meet the following requirements: Match the specified HKQuantityType. Are associated with the containing workout. Fall within the activity’s time frame. Furthermore, if a quantity sample extends beyond the activity’s time frame, HealthKit interpolates a quantity value to represent the portion within the time frame, and uses that value instead. If there are no matching quantity values, this method returns nil.

## See Also

### Accessing workout data

- [uuid](healthkit/hkworkoutactivity/uuid.md)
- [startDate](healthkit/hkworkoutactivity/startdate.md)
- [endDate](healthkit/hkworkoutactivity/enddate.md)
- [duration](healthkit/hkworkoutactivity/duration.md)
- [allStatistics](healthkit/hkworkoutactivity/allstatistics.md)
- [metadata](healthkit/hkworkoutactivity/metadata.md)
- [workoutConfiguration](healthkit/hkworkoutactivity/workoutconfiguration.md)
- [workoutEvents](healthkit/hkworkoutactivity/workoutevents.md)
