<!--
{
  "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/predicateForWorkouts(operatorType:quantityType:sumQuantity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuery(cm)predicateForWorkoutsWithOperatorType:quantityType:sumQuantity:"
  },
  "title" : "predicateForWorkouts(operatorType:quantityType:sumQuantity:)"
}
-->

# predicateForWorkouts(operatorType:quantityType:sumQuantity:)

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

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

## Parameters

`operatorType`

The operator type to use when comparing the sum.

`quantityType`

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

`sumQuantity`

The target value for the sum.

## Discussion

Use this convenience method to create a predicate that matches workouts with the specified total value. For more information on how HealthKit calculates statistics for [`HKWorkoutActivity`](/documentation/HealthKit/HKWorkoutActivity) objects, see [`statistics(for:)`](/documentation/HealthKit/HKWorkoutActivity/statistics(for:)).

The following sample creates a predicate for workout activities with a total step count of 1000 or higher.

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

let expectedQuantity = HKQuantity(unit: .count(),
                                  doubleValue: 1000.0)

let stepCountPredicate = HKQuery.predicateForWorkouts(
    operatorType: .greaterThanOrEqualTo,
    quantityType: quantityType,
    sumQuantity: expectedQuantity)
```

---

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)