HKStatisticsCollectionQueryDescriptor intermittently returns no data for certain date ranges on iOS 27

We are seeing inconsistent results from HKStatisticsCollectionQueryDescriptor on iOS 27.

Using the same quantity type, statistics options, anchor date, interval components, and predicate configuration, some date ranges return the expected statistics, while other ranges unexpectedly return empty results or buckets with no quantity.

The affected ranges do contain HealthKit samples:

  • HKSampleQueryDescriptor finds samples in the same date range.
  • HKStatisticsQueryDescriptor returns the expected value when run separately for an affected bucket.
  • HKStatisticsCollectionQueryDescriptor returns no quantity for that same bucket.
  • Slightly expanding or shifting the date range may cause the collection query to return data again.

A simplified version of the query looks like this:

let datePredicate = HKQuery.predicateForSamples(
    withStart: startDate,
    end: endDate,
    options: .strictStartDate
)

let descriptor = HKStatisticsCollectionQueryDescriptor(
    predicate: .quantitySample(
        type: quantityType,
        predicate: datePredicate
    ),
    options: .cumulativeSum,
    anchorDate: anchorDate,
    intervalComponents: DateComponents(day: 1)
)

let collection = try await descriptor.result(for: healthStore)

collection.enumerateStatistics(from: startDate, to: endDate) {
    statistics,
    _ in

    let quantity = statistics.sumQuantity()
    print(statistics.startDate, quantity as Any)
}

Expected behavior

Every interval containing matching samples should return the corresponding statistics, regardless of the overall requested date range.

Actual behavior

Some date ranges produce missing or empty buckets even though matching samples exist and an individual HKStatisticsQueryDescriptor can calculate the expected value. Changing only the date range can make the data appear or disappear.

The samples are visible to the app in the affected range, so this does not appear to be explained solely by iOS 27’s Limited History authorization.

This behavior was not observed with the same query flow on earlier iOS versions.

Is this a known regression in HKStatisticsCollectionQueryDescriptor on iOS 27, or has the expected date-range or predicate behavior changed?

Same issue, have you got a solution, or a workaround ? Thanks 🙏

same issue here, HKStatisticsCollectionQuery does not respond correct data for every user. When we try to select 'limited acces' on the apple health it fixes the problem. But 'full access' is the still problematic at this moment.

Need quick fix

Same issue is here in CardioBot app.

I can't tell you whether this is an iOS 27 regression, and I want that out of the way before the rest of it — I only ever ran this query shape on iOS 27, so I have no earlier data point to compare against. Your symptom is also milder than mine: yours is intermittent and range-dependent, mine was every bucket, every day, deterministically.

But there is one variable in your sample code that nobody in this thread has ruled out yet, and on my device it is the difference between a correct answer and nothing at all: .strictStartDate.

Measured on iOS 27.0 (24A437), one device, one day, one quantity type (basalEnergyBurned), four combinations in a single run:

plain sum,         .strictStartDate -> 2138
plain sum,         no options       -> 2206
hourly collection, .strictStartDate -> total=0    intervals=25
hourly collection, no options       -> total=2206

Same day, same type, same store. The option costs the plain query 68 calories and zeroes the collection query completely.

On the plain query that is exactly the documented behavior, and you can account for it to the calorie. The docs read "The sample’s start time must fall within the target time period.", there is one target the size of the whole range, and my probe day has exactly one sample starting before it — 04:59:15, 67 calories. 2206 - 67 = 2139, near enough the 2138 measured.

The collection query is where I stop being able to explain it, and I'd rather say so than hand you a theory that doesn't hold. If "target" means the intervals, the same rule should cost one sample per boundary — but every sample's start falls inside some hour, so it should land in that hour's bucket. Here are the first four samples of the probe day, against a day starting at 05:00:00:

04:59:15 -> 05:53:33   67 cal
05:53:33 -> 05:53:54    0
05:53:54 -> 06:13:01   23
06:13:01 -> 06:13:42    1

05:53:33 and 05:53:54 start inside the 05:00 hour; 06:13:01 starts inside the 06:00 hour. That reading predicts an hourly total around 2139, the same as the strict plain sum. I measured zero, across all 25 intervals. So whatever is happening is larger than the documented rule, and if anything that is evidence for your side of it — this option should not be able to empty a whole day.

Worth running before you wait on a fix: execute your descriptor twice in the same run, once with options: .strictStartDate and once with options: [], and print both. It takes one build. If the loose run is correct and the strict run is empty, it is the predicate rather than the store, and dropping the option is defensible anyway — without it HealthKit apportions a straddling sample across the intervals it overlaps, which is usually what a cumulative total wants.

On the limited-access-versus-full-access report above: I only ever measured with full access granted, so I can't tell you whether that interacts with this. If you can reproduce it under one and not the other, that is a second one-variable comparison and a more interesting one than mine.

Two caveats so this isn't taken further than it goes. .strictEndDate is not the fix — on the plain query it moves the loss to the other boundary rather than removing it. And if your samples are genuinely instantaneous (dietary energy, body mass), this isn't your cause; I measured a delta of exactly zero for those types.

One thread that may bear on the regression question, with the caveat that it may not be the same thing: 786576, June 2025, reports this option quietly losing the first interval of an hourly basalEnergyBurned collection query, with the low interval moving when the window moved. That is a partial loss and it is what the documented rule predicts. Mine is a total loss and isn't. Two mechanisms or one, I don't know.

Full write-up, with the three wrong diagnoses it took to get there: https://mcmizzle.com/blog/healthkit-collection-query-returns-zero/