I have entries coming in every day and sometimes twice a day with same value. The same value can come in next day or next week too. I need to sum these values so they are distinct only for that day and still count towards the sum even if it same value the next day. I have tried the below but this will only count as one distinct occurrence where in fact there is another one the next day. Perhaps there is another way to this. Any way I can achieve this?
Measurement _field _value _time
GBP. value. 3.2. 2023-05-10T09:00:00.000Z
GBP. value. 3.2. 2023-05-10T12:00:00.000Z
GBP. value. 3.2. 2023-06-02T10:00:00.000Z
Expected sum 6.4 as there is a duplicate for day 2023-05-10T09:00:00.000Z
import "date"
from(bucket: "homeassistant_db")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "GBP")
|> filter(fn: (r) => r["entity_id"] == "my_cost1")
|> filter(fn: (r) => r["friendly_name"] == "my_friendly_cost1")
|> filter(fn: (r) => r["_field"] == "value")
|> distinct(column: "_value")
|> sum(column: "_value")