# Add a custom field to a query

**URL:** <https://community.influxdata.com/t/add-a-custom-field-to-a-query/28930>\
**Category:** InfluxDB 2\
**Tags:** influxdb, flux\
**Created:** [March 6, 2023, 4:56pm UTC](https://community.influxdata.com/t/add-a-custom-field-to-a-query/28930 "2023-03-06T16:56:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guilherme\_Ladvocat](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/guilherme_ladvocat/32/10612_2.png) [@Guilherme\_Ladvocat](https://community.influxdata.com/u/Guilherme_Ladvocat)\
**Post date:** [March 6, 2023, 4:56pm UTC](https://community.influxdata.com/t/add-a-custom-field-to-a-query/28930/1 "2023-03-06T16:56:04Z")

</div>

I am trying to make a combined query, assigning a value to a variable and passing it to the main query. I think it is due the result type of the first query, that is not a simple string.

```auto
desc = v1.tagValues(
    bucket: "telemetry",
    tag: "/interfaces/interface/subinterfaces/subinterface/state/description",
    predicate: (r) => r["device"] == "cpr1" and r["interface_name"] == "${core_int}" and r["subinterface_index"] == "3000",
    start: -1d
)

from(bucket: "telemetry")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "/interfaces/")
  |> filter(fn: (r) => r["_field"] == "/interfaces/interface/subinterfaces/subinterface/state/counters/in-octets")
  |> filter(fn: (r) => r["device"] == "${device}")
  |> filter(fn: (r) => r["interface_name"] == "${core_int}")
  |> map(fn: (r) => ({r with _value: r._value * 8}))
  |> derivative(nonNegative: true, unit: 1s)
  |> set(key: "_field", value: "input")
  |> set(key: "_desc", value: "${desc}")

```

Error received:  
invalid: error @22:34-22:38: stream[{A with \_value: B, \_value: string}] is not Stringable

---

<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:** [March 8, 2023, 10:24pm UTC](https://community.influxdata.com/t/add-a-custom-field-to-a-query/28930/2 "2023-03-08T22:24:56Z")

</div>

Hello @Guilherme_Ladvocat,  
I recommend yeilding desc to get an understanding for what type it is.  
It’s a table.  
You can extract a single record:

```auto
desc = schema.tagValues(bucket: "airSensors", tag: "sensor_id",
predicate: (r) => r["_measurement"] == "airSensors",
start: -1y
    )
|> findRecord(
        fn: (key) => true,
        idx: 0,
    )

desc._value

```

Then you cold pass it into your subsequent query.

---

<div class="post-metadata">

**Author:** ![Guilherme\_Ladvocat](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/guilherme_ladvocat/32/10612_2.png) [@Guilherme\_Ladvocat](https://community.influxdata.com/u/Guilherme_Ladvocat)\
**Post date:** [March 8, 2023, 11:21pm UTC](https://community.influxdata.com/t/add-a-custom-field-to-a-query/28930/3 "2023-03-08T23:21:11Z")

</div>

Hi @Anaisdg,

When I do a query with the ‘findRecord’ function, I receive this message:  
“error in query specification while starting program: this Flux script returns no streaming data. Consider adding a “yield” or invoking streaming functions directly, without performing an assignment”

And when I do without it, I see data, but in a table.

 ![Screenshot from 2023-03-08 20-14-37](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/b/b2709d9d5a06a864762f26f9955d845cd0af7e91.png)
