<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 8.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKSamplePredicate/correlation(type:predicate:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit17HKSamplePredicateV11correlation4type9predicateACySo13HKCorrelationCGSo0H4TypeC_So11NSPredicateCSgtFZ"
  },
  "title" : "correlation(type:predicate:)"
}
-->

# correlation(type:predicate:)

Returns a sample predicate that matches samples that contain correlated data.

```
static func correlation(type correlationType: HKCorrelationType, predicate: NSPredicate? = nil) -> HKSamplePredicate<HKCorrelation>
```

## Parameters

`correlationType`

A type that matches samples that contain a set of subsamples.

`predicate`

An optional predicate that further restricts the results that the query returns.

## Discussion

Use this method to create an [`HKSamplePredicate`](/documentation/HealthKit/HKSamplePredicate) instance that you can use to query for [`HKCorrelation`](/documentation/HealthKit/HKCorrelation) objects.

---

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)