Fields are returned in some timeframes but not in others

This is my flux query, where I have removed the field check I usually have there:

from(bucket: "telegraf-misc")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "sofar.logger.ActivePower_Load_Sys")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

When running this query for the last 6 months I get a lot of data, both for the start_time_unix_nano field and the gauge field.

But when I select last 7 months, I suddenly don’t get data for the gauge field anymore, only for the start_time_unix_nano field.

(Sorry I had to cram the images together, the forum only allows one image)

I think this is happening since I tried to import data from an older database via the “Upload a CSV” feature, and it didn’t quite work. Similar to this issue, I could only ever see either the imported data or the data from telegraf. When I selected a timeframe which would have both, I saw no data.
I tried deleting it like so:
influx delete --bucket telegraf-misc --predicate _measurement=\"sofar.logger.ActivePower_Load_Sys\" --start "2023-01-01T23:55:00Z" --stop "2023-07-10T23:00:00Z"
The deletion worked, but ever since then I have this issue and I don’t know what to do about it/how to debug it.

Hello @node1,
The InfluxDB UI is notorious for having problems/bugs. But not grafana. But it could be a grafana issue. Do you encounter this problem when you query with a client library or cURL request?

It could also be that an aggregation is automatically being applied? Which is concealing some of your data when you select for a bigger time window?

I just tried it with curl and I have the exact same problem.
With one timespan, I get no values having the gauge field at all.

I’m not sure what kind of aggregation there should be. I tried it even without aggregateWindow():

This has a lot of output (as expected) and gives me the correct data:

curl -XPOST localhost:8086/api/v2/query?orgID=myorgid -sS -H 'Accept:application/csv' -H 'Cookie: mycookie' -H 'Content-type:application/vnd.flux' -d 'from(bucket: "telegraf-misc")
  |> range(start: 2023-07-18T20:59:50.038Z, stop: 2024-01-18T21:59:50.038Z)
  |> filter(fn: (r) => r["_measurement"] == "sofar.logger.ActivePower_Load_Sys")
  |> filter(fn: (r) => r["_field"] == "gauge")'
...
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:28:36.541637584Z,28,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:28:38.568850591Z,28,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:28:43.530898723Z,28,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:28:48.434313432Z,27,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:28:53.553001964Z,29,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:28:58.565075068Z,28,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:29:03.474355436Z,27,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
,_result,0,2023-07-18T20:59:50.038Z,2024-01-18T21:59:50.038Z,2023-07-24T02:29:09.438773538Z,26,gauge,sofar.logger.ActivePower_Load_Sys,kevin,sofar.logging
...

This, on the other hand, gives no output at all (notice the difference in the start of the timerange):

curl -XPOST localhost:8086/api/v2/query?orgID=myorgid -sS -H 'Accept:application/csv' -H 'Cookie: mycookie' -H 'Content-type:application/vnd.flux' -d 'from(bucket: "telegraf-misc")
  |> range(start: 2023-06-18T20:59:50.038Z, stop: 2024-01-18T21:59:50.038Z)
  |> filter(fn: (r) => r["_measurement"] == "sofar.logger.ActivePower_Load_Sys")
  |> filter(fn: (r) => r["_field"] == "gauge")'