<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuery/predicateForWorkoutActivities(operatorType:quantityType:averageQuantity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuery(cm)predicateForWorkoutActivitiesWithOperatorType:quantityType:averageQuantity:"
  },
  "title" : "predicateForWorkoutActivities(operatorType:quantityType:averageQuantity:)"
}
-->

# predicateForWorkoutActivities(operatorType:quantityType:averageQuantity:)

Returns a predicate for matching workout activities based the average value of an associated quantity type.

```
class func predicateForWorkoutActivities(operatorType: NSComparisonPredicate.Operator, quantityType: HKQuantityType, averageQuantity: HKQuantity) -> NSPredicate
```

## Parameters

`operatorType`

The operator type to use when comparing the average quantity.

`quantityType`

The type of [`HKQuantitySample`](/documentation/HealthKit/HKQuantitySample) objects used to calculate the average quantity.

`averageQuantity`

The target value for the average quantity.

## Discussion

Use this convenience method to create a predicate that matches workouts with the specified average quantity. To use this predicate, call [`predicateForWorkouts(activityPredicate:)`](/documentation/HealthKit/HKQuery/predicateForWorkouts(activityPredicate:)) to wrap this predicate inside a workout predicate. You can then use the workout predicate in your query.

The following sample creates a predicate for workout activities with an average heart rate of 150 bmp or higher.

```swift
let quantityType = HKQuantityType(.heartRate)

let expectedQuantity =
HKQuantity(unit: .count().unitDivided(by: .minute()),
           doubleValue: 150.0)

let heartRatePredicate =
HKQuery.predicateForWorkoutActivities(
    operatorType: .greaterThanOrEqualTo,
    quantityType: quantityType,
    averageQuantity:
        expectedQuantity
)

// Wrap the activity predicate inside a workout predicate.
let workoutPredicate = HKQuery.predicateForWorkouts(activityPredicate: heartRatePredicate)
```

For more information on how HealthKit calculates statistics for [`HKWorkoutActivity`](/documentation/HealthKit/HKWorkoutActivity) objects, see [`statistics(for:)`](/documentation/HealthKit/HKWorkoutActivity/statistics(for:)).

---

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)