# Need help. Influxdb1 vs. influxdb2 with flux

**URL:** <https://community.influxdata.com/t/need-help-influxdb1-vs-influxdb2-with-flux/31720>\
**Category:** InfluxDB 2\
**Created:** [October 5, 2023, 8:24am UTC](https://community.influxdata.com/t/need-help-influxdb1-vs-influxdb2-with-flux/31720 "2023-10-05T08:24:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![voosa](https://avatars.discourse-cdn.com/v4/letter/v/51bf81/32.png) [@voosa](https://community.influxdata.com/u/voosa)\
**Post date:** [October 5, 2023, 8:24am UTC](https://community.influxdata.com/t/need-help-influxdb1-vs-influxdb2-with-flux/31720/1 "2023-10-05T08:24:23Z")

</div>

Hi everyone,

i am trying to migrate my influxdb1 statements to influxdb2 with flux. But i have problems to get the same result like the old one. ☹ Hope u can help 🙂

this is the old statement

SELECT difference(last(“value”)) FROM “smartmeter.0.1-0:1\_8\_0\_\_255.value” WHERE $timeFilter GROUP BY time(24h) fill(null)

 ![Screenshot 2023-10-05 101612](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/2/288f0e91e05efa3defd6930ad59865d8b02847ae.png)

bucket: “iobroker”

i tried a few statements but its not working like before. ☹

BR

Ben

---

<div class="post-metadata">

**Author:** ![Ravikant\_Gautam](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ravikant_gautam/32/5700_2.png) [@Ravikant\_Gautam](https://community.influxdata.com/u/Ravikant_Gautam)\
**Post date:** [October 5, 2023, 8:35am UTC](https://community.influxdata.com/t/need-help-influxdb1-vs-influxdb2-with-flux/31720/2 "2023-10-05T08:35:29Z")

</div>

could you please explain your query in simple sentences what you want to achieve using the query?

---

<div class="post-metadata">

**Author:** ![voosa](https://avatars.discourse-cdn.com/v4/letter/v/51bf81/32.png) [@voosa](https://community.influxdata.com/u/voosa)\
**Post date:** [October 5, 2023, 8:40am UTC](https://community.influxdata.com/t/need-help-influxdb1-vs-influxdb2-with-flux/31720/3 "2023-10-05T08:40:23Z")

</div>

sure 🙂 . i have a simple value in the database. Its the Energy Counter. Its just an increasing value so i need the difference group by 24 hours. So that i have the increase for a day.

---

<div class="post-metadata">

**Author:** ![voosa](https://avatars.discourse-cdn.com/v4/letter/v/51bf81/32.png) [@voosa](https://community.influxdata.com/u/voosa)\
**Post date:** [October 5, 2023, 9:47am UTC](https://community.influxdata.com/t/need-help-influxdb1-vs-influxdb2-with-flux/31720/4 "2023-10-05T09:47:24Z")

</div>

finally it works! try and error 🙂

from(bucket: “iobroker”)  
|\> range(start: -360d, stop: now())  
|\> filter(fn: (r) =\> r[“\_measurement”] == “smartmeter.0.1-0:1\_8\_0\_\_255”)  
|\> filter(fn: (r) =\> r[“\_field”] == “value”)  
|\> aggregateWindow(every: 24h, fn: last, createEmpty: false)  
|\> difference(columns: [“\_value”])  
|\> group(columns: [“\_time($interval)”], mode: “by”)  
|\> fill(column: “\_value”, usePrevious: true)  
|\> sort(columns: [“\_time”], desc: true)

thx anyway
