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

# predicateForWorkouts(operatorType:quantityType:maximumQuantity:)

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

## Declaration

```swift
class func predicateForWorkouts(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 workouts with the specified maximum quantity. For more information on how HealthKit calculates statistics for HKWorkoutActivity objects, see statistics(for:). 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.predicateForWorkouts(     operatorType: .greaterThanOrEqualTo,     quantityType: quantityType,     maximumQuantity: expectedQuantity) }

## See Also

### Creating workout predicates

- [predicateForObjects(from:)](healthkit/hkquery/predicateforobjects(from:)-5irg9.md)
- [predicateForWorkouts(with:)](healthkit/hkquery/predicateforworkouts(with:).md)
- [predicateForWorkouts(activityPredicate:)](healthkit/hkquery/predicateforworkouts(activitypredicate:).md)
- [predicateForWorkouts(with:duration:)](healthkit/hkquery/predicateforworkouts(with:duration:).md)
- [predicateForWorkouts(operatorType:quantityType:averageQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:averagequantity:).md)
- [predicateForWorkouts(operatorType:quantityType:minimumQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:minimumquantity:).md)
- [predicateForWorkouts(operatorType:quantityType:sumQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:sumquantity:).md)
- [predicateForWorkouts(with:totalDistance:)](healthkit/hkquery/predicateforworkouts(with:totaldistance:).md)
- [predicateForWorkouts(with:totalEnergyBurned:)](healthkit/hkquery/predicateforworkouts(with:totalenergyburned:).md)
- [predicateForWorkouts(with:totalFlightsClimbed:)](healthkit/hkquery/predicateforworkouts(with:totalflightsclimbed:).md)
- [predicateForWorkouts(with:totalSwimmingStrokeCount:)](healthkit/hkquery/predicateforworkouts(with:totalswimmingstrokecount:).md)
