Kapacitor difference

kapacitor

#1

I have a mesurement like this

TIME iD SOLD_QUANTITY
XXX 1 1
XXX 1 2
XXX 1 2
XXX 2 1
XXX 2 1

I wish with kapacitor get the difference betweent last value and new value with stream. I trying to do:

dbrp “ml”.“autogen”

stream
|from().measurement(‘items’).groupBy(‘item_id’)
|window().period(1d)
|difference(‘sold_quantity’)
|log()

But dont work, some body can help me. Thanks


#2

Can you post your expected result versus actual result? That would be helpful!


#3

I have something like this: table products
time . item_id . sold
xxxxxxx 1 4
xxxxxxx 1 6
xxxxxxx 1 7
xxxxxxx 1 7
xxxxxxx 1 8

and i put a new record
xxxxxxx 1 9

My spected result is the diffrence betweent the lastrecord and new record:
xxxxxxx 1 1

and output this into influxdb table.