# Delete datapoint with same value

**URL:** <https://community.influxdata.com/t/delete-datapoint-with-same-value/33632>\
**Category:** InfluxDB 2\
**Created:** [March 20, 2024, 1:05am UTC](https://community.influxdata.com/t/delete-datapoint-with-same-value/33632 "2024-03-20T01:05:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user642](https://avatars.discourse-cdn.com/v4/letter/u/cab0a1/32.png) [@user642](https://community.influxdata.com/u/user642)\
**Post date:** [March 20, 2024, 1:05am UTC](https://community.influxdata.com/t/delete-datapoint-with-same-value/33632/1 "2024-03-20T01:05:13Z")

</div>

Im saving the data from my gas meter to a database. Every 30mins im getting the current meter reading.

When there is no change i only want to keep the first entry

for example:  
#1 1:00 8738m²  
#2 1:30 8740m²  
#3 2:00 8740m²  
#4 2:30 8740m²  
#5 3:00 8744m²

in this case i want to use a task job but i dont want to keep #3 and #4.  
how can i do this?

---

<div class="post-metadata">

**Author:** ![Zoe\_Steinkamp](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/zoe_steinkamp/32/13300_2.png) [@Zoe\_Steinkamp](https://community.influxdata.com/u/Zoe_Steinkamp)\
**Post date:** [March 21, 2024, 4:49pm UTC](https://community.influxdata.com/t/delete-datapoint-with-same-value/33632/2 "2024-03-21T16:49:38Z")

</div>

I found this as a suggestion from another user

```auto
from(bucket: "sensors")
  # Usual range and filter.
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._field == "temp")

  # Copy "_value" column so that the original won't get lost.
  |> duplicate(column: "_value", as: "diff")

  # Convert "diff"-column to the difference from pervious row.
  |> difference(
    columns: ["diff"],
    keepFirst: true # Stores null in first "diff"-column.
  )

  # Keep the first null-valued row; it is the initial value,
  # and all other rows with a change (diff != 0).
  |> filter(fn: (r) => not exists r.diff or r.diff != 0)

```
