---
title: "predicateForWorkoutActivities(operatorType:quantityType:maximumQuantity:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:maximumquantity:)"
---

# predicateForWorkoutActivities(operatorType:quantityType:maximumQuantity:)

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

## Declaration

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

## Parameters

- `operatorType`: The operator type to use when comparing the maximum quantity.
- `quantityType`: The type of doc://com.apple.healthkit/documentation/HealthKit/HKQuantitySample objects used to calculate the maximum quantity.
- `maximumQuantity`: The target value for the maximum quantity.

## Discussion

Discussion Use this convenience method to create a predicate that matches workout activities with the specified maximum quantity. To use this predicate, call 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 a maximum heart rate of 150 bmp or higher. let quantityType = HKQuantityType(.heartRate)

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

let heartRatePredicate = HKQuery.predicateForWorkoutActivities(     operatorType: .greaterThanOrEqualTo,     quantityType: quantityType,     maximumQuantity:         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 objects, see statistics(for:).

## See Also

### Creating workout activity predicates

- [predicateForWorkoutActivities(workoutActivityType:)](healthkit/hkquery/predicateforworkoutactivities(workoutactivitytype:).md)
- [predicateForWorkoutActivities(operatorType:duration:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:duration:).md)
- [predicateForWorkoutActivities(start:end:options:)](healthkit/hkquery/predicateforworkoutactivities(start:end:options:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:averageQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:averagequantity:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:minimumQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:minimumquantity:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:sumQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:sumquantity:).md)
