Kapacitor difference

I have a mesurement like this

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”


But dont work, some body can help me. Thanks

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

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.