# How to do simple value manipulations of existing values in influxDB

**URL:** <https://community.influxdata.com/t/how-to-do-simple-value-manipulations-of-existing-values-in-influxdb/27836>\
**Category:** InfluxQL\
**Tags:** chronograf, query\
**Created:** [December 22, 2022, 10:32am UTC](https://community.influxdata.com/t/how-to-do-simple-value-manipulations-of-existing-values-in-influxdb/27836 "2022-12-22T10:32:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RedwoodRed](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RedwoodRed](https://community.influxdata.com/u/RedwoodRed)\
**Post date:** [December 22, 2022, 10:32am UTC](https://community.influxdata.com/t/how-to-do-simple-value-manipulations-of-existing-values-in-influxdb/27836/1 "2022-12-22T10:32:44Z")

</div>

**Setup:**  
I’m using Chronograf 1.10.0 (on Docker) on influxDB 1.8 (on Docker) to store data of my smarthome installation (openHAB, also on Docker).

**Task:**  
Due to a logic change of one of my sensors, my energy measurements are now stored as “kWh per day” (vs. previously “average kW per 24 hours”). To have consistent data, I’d like to replace all values of a certain table with “old value \* 24”. What I like to do is very similar to what’s reported reported (and solved) [here](https://community.influxdata.com/t/update-values-which-are-smaller-than-x/18595). However, I was not able to apply the solution presented there to my problem. I’ve tried different approaches, each leading to roadblocks.

**Option / Problem 1:** Apply the example above in Chronograf.  
If I apply the code to my setting…

```auto
from(bucket: "openhab_db/autogen")
|> range(start: -2y, stop: now())
|> filter(fn: (r) => r._measurement == "RainPastHour")
|> map(fn: (r) => ({ r with _value: r._value * 24 }))
|> to(bucket: "openhab_db/autogen")

```

… I’m getting the error `error calling function "to": function "to" is not implemented`. [Here](https://community.influxdata.com/t/join-big-measurements-together-error-bad-gateway/15543/6) I read that Flux in InfluxDB 1.x is read-only, so I am not able to write data back to InfluxDB. Is this true? If yes, what’s the alternative? Using influxQL instead?

**Option / Problem 2:** Use influxQL in Chronograf.  
Assuming that Flux cannot write data, I tried switching to influxQL in Chronograf. If I run the following query…  
`UPDATE RainPastHour SET RainPastHour = RainPastHour * 24 where time > '2022-01-11 08:00:00' and time < '2022-12-11 12:00:00'`  
… I get the error `error parsing query: found UPDATE, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1`, so obviously this won’t work as well.

Which brings me back to square 1: How do I change data in influxDB 1.8?

Thanks a lot in advance for anyone who can help me.

---

<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:** [December 27, 2022, 6:56pm UTC](https://community.influxdata.com/t/how-to-do-simple-value-manipulations-of-existing-values-in-influxdb/27836/2 "2022-12-27T18:56:18Z")

</div>

Hello @RedwoodRed,  
Unfortunately, that is true of 1.x you must upgrade to 2.x to take advantage of the to() function.  
Unfortunately, you can’t perform updates with InfluxQL.

You can simply overwrite existing points assuming they have the same series (same combination of measurement, tag set, and field keys).  
For example if your old data was written with:  
`mymeasurement, tagkey1=mytagkey1value fieldkey1=24 1672167317`  
If you then wrote:  
`mymeasurement, tagkey1=mytagkey1value fieldkey1=100 1672167317`  
The second point would replace the first and you would overwrite your data.

So you must either upgrade or rewrite values to InfluxDB.

> **[InfluxDB design insights and tradeoffs | InfluxDB OSS 1.8 Documentation](https://docs.influxdata.com/influxdb/v1.8/concepts/insights_tradeoffs/)**
>
> Optimizing for time series use case entails some tradeoffs, primarily to increase performance at the cost of functionality.

---

<div class="post-metadata">

**Author:** ![RedwoodRed](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RedwoodRed](https://community.influxdata.com/u/RedwoodRed)\
**Post date:** [December 28, 2022, 10:27pm UTC](https://community.influxdata.com/t/how-to-do-simple-value-manipulations-of-existing-values-in-influxdb/27836/3 "2022-12-28T22:27:17Z")

</div>

Thanks a lot @Anaisdg, for your explanation. This confirms my assumptions.

[Here‘s](https://community.openhab.org/t/use-case-how-to-delete-or-change-item-values-in-openhabs-influxdb/142452?u=cplant) what I made out of it (documented it both for myself as well as for others from the openHAB community who might use influxDB as well / facing similar changes).

If you see something overly stupid in there, let me know.
