# How transform bytes to GB in the output table?

**URL:** <https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433>\
**Category:** InfluxQL\
**Tags:** grafana, query, flux\
**Created:** [February 3, 2023, 2:55pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433 "2023-02-03T14:55:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1192410](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/1192410/32/12569_2.png) [@1192410](https://community.influxdata.com/u/1192410)\
**Post date:** [February 3, 2023, 2:55pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/1 "2023-02-03T14:55:22Z")

</div>

Hi,

I’m trying to dsiplay the daily input and output of my Fritzbox in a Grafana Dashboard.

from(bucket: “homeassistant\_stage”)  
|\> range(start: v.timeRangeStart, stop: v.timeRangeStop)  
|\> filter(fn: (r) =\> r[“entity\_id”] == “fritz\_box\_7590\_ax\_b\_received”)  
|\> filter(fn: (r) =\> r[“\_field”] == “value”)  
|\> filter(fn: (r) =\> r[“\_measurement”] == “B”)  
|\> aggregateWindow(every: 1d, fn: mean, createEmpty: false)  
|\> yield(name: “mean”)

I’m getting the correct data in the output table, however I’m struggeling with the conversion part ?

Any help would be much appreciated.

Thanks, Andreas

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [February 3, 2023, 4:31pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/2 "2023-02-03T16:31:22Z")

</div>

Welcome Andreas (@1192410 ) to the Influx Community Forum.

Have you seen / tried this? [Transform data with mathematic operations in Flux | InfluxDB OSS 2.6 Documentation](https://docs.influxdata.com/influxdb/v2.6/query-data/flux/mathematic-operations/#convert-bytes-to-gigabytes)

---

<div class="post-metadata">

**Author:** ![1192410](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/1192410/32/12569_2.png) [@1192410](https://community.influxdata.com/u/1192410)\
**Post date:** [February 3, 2023, 7:09pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/3 "2023-02-03T19:09:16Z")

</div>

Thanks for the link. I’ve seen that, but it gives me an error.

from(bucket: “homeassistant\_stage”)

> > range(start: -10m)  
> > filter(fn: (r) =\> r.\_measurement == “B” and r.entity\_id == “fritz\_box\_7590\_ax\_b\_received”)  
> > map(fn: (r) =\> ({r with \_value: r.\_value / 1073741824}))

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [February 4, 2023, 11:12pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/4 "2023-02-04T23:12:38Z")

</div>

Hi @1192410  
 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/c/c1b0697ea07612d99b757ebc1c82e5e98f793b09.png)

My guess is that your `_value` is actually being stored as a string. I think you could use the `|> toInt()` function and make it work. Can you try this?

```auto
from(bucket: "homeassistant_stage")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "B" and r.entity_id == "fritz_box_7590_ax_b_received")
|> toInt()
|> map(fn: (r) => ({r with _value: r._value / 1073741824}))
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

```

---

<div class="post-metadata">

**Author:** ![1192410](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/1192410/32/12569_2.png) [@1192410](https://community.influxdata.com/u/1192410)\
**Post date:** [February 5, 2023, 9:21am UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/5 "2023-02-05T09:21:35Z")

</div>

Thanks @grant1. I have tried it, but still an error.

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

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [February 5, 2023, 12:40pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/6 "2023-02-05T12:40:02Z")

</div>

@1192410 It definitely seems that the \_value column is a string (instead of an integer). I read through [this post](https://community.influxdata.com/t/change-type-from-string-to-integer/18634/33) and the conclusion seemed to be to re-populate the data correctly.

The error you received references a column called “data\_size”, but I do not see that in your original output:

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

How are these values getting sent in? Are the commas in \_value there, or being added by InfluxDB? I believe InfluxDB is seeing those values as strings.

Can you go to the system where the data is being scraped and sent into Influx and check your settings there?

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [February 5, 2023, 12:46pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/7 "2023-02-05T12:46:55Z")

</div>

I just saw that you are using Grafana. Can you try the transformation there, like this?

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

and if that works, we can convert to GB using a second Grafana transformation.

---

<div class="post-metadata">

**Author:** ![grant1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grant1/32/15107_2.png) [@grant1](https://community.influxdata.com/u/grant1)\
**Post date:** [February 5, 2023, 12:51pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/8 "2023-02-05T12:51:20Z")

</div>

Not really a great example, but it should look something like this when done:

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/e/e30f0bb5c62919f8afc4353d5fdcb42f764ca0bc.png)  
(for the Operation, change the + to a / )

---

<div class="post-metadata">

**Author:** ![1192410](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/1192410/32/12569_2.png) [@1192410](https://community.influxdata.com/u/1192410)\
**Post date:** [February 5, 2023, 2:22pm UTC](https://community.influxdata.com/t/how-transform-bytes-to-gb-in-the-output-table/28433/9 "2023-02-05T14:22:51Z")

</div>

Thanks, Grafana worked. I did it with the override section. It automatically changed the values from bytes to GB.

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