# Fields are returned in some timeframes but not in others

**URL:** <https://community.influxdata.com/t/fields-are-returned-in-some-timeframes-but-not-in-others/32796>\
**Category:** InfluxDB 2\
**Tags:** influxdb, telegraf, grafana, flux\
**Created:** [January 13, 2024, 11:10pm UTC](https://community.influxdata.com/t/fields-are-returned-in-some-timeframes-but-not-in-others/32796 "2024-01-13T23:10:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![node1](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@node1](https://community.influxdata.com/u/node1)\
**Post date:** [January 13, 2024, 11:10pm UTC](https://community.influxdata.com/t/fields-are-returned-in-some-timeframes-but-not-in-others/32796/1 "2024-01-13T23:10:35Z")

</div>

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

```flux
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.

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/f/f6824ff22457ff0ac7ed41a15fbc0b80be3e23c0.png)

(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.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [January 18, 2024, 7:29pm UTC](https://community.influxdata.com/t/fields-are-returned-in-some-timeframes-but-not-in-others/32796/2 "2024-01-18T19:29:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![node1](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@node1](https://community.influxdata.com/u/node1)\
**Post date:** [January 18, 2024, 10:14pm UTC](https://community.influxdata.com/t/fields-are-returned-in-some-timeframes-but-not-in-others/32796/3 "2024-01-18T22:14:19Z")

</div>

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:

```auto
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")'

```

```auto
...
,_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):

```auto
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")'

```

```auto

```
