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

# statistics(for:)

Returns the workout’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 associated with the workout that also match the specified HKQuantityType. If there are no matching quantity values, this method returns nil.

## See Also

### Accessing workout data

- [duration](healthkit/hkworkout/duration.md)
- [workoutActivityType](healthkit/hkworkout/workoutactivitytype.md)
- [workoutActivities](healthkit/hkworkout/workoutactivities.md)
- [workoutEvents](healthkit/hkworkout/workoutevents.md)
- [allStatistics](healthkit/hkworkout/allstatistics.md)
- [totalDistance](healthkit/hkworkout/totaldistance.md)
- [totalEnergyBurned](healthkit/hkworkout/totalenergyburned.md)
- [totalFlightsClimbed](healthkit/hkworkout/totalflightsclimbed.md)
- [totalSwimmingStrokeCount](healthkit/hkworkout/totalswimmingstrokecount.md)
