How to compare 2 consecutive series of data and the ways to access/compare variables in Tick?

Hi,

Query 1 :

Is there anyway we can compare the 2 consecutive series of data. I found, shift(-1m) which gives the previous 1m data. But i want to compare within the continuous stream.

Query 2:
How to access a field or tag from the variable which has collected the stream.

for ex:
     var current = stream
    |from()
    .measurement('example')
    .groupBy(*)
    |window()
    .period(1m)
    .every(1m)
        var old = current 
        |shift(-1m)

        |alert()
        .id('/jobs:jobs/telemetry-measurement:measurement/measurement=test/query=test')
        .crit(lambda: ("current".'device'=="old".'device'))

Though the condition has met, its not giving any result.

I have tried all the combinations with single and double quotes. only this seems to working but no result.

Query 3:

How to compare the variable result with any other tag or field in SELECT statement or lambda condition.

dbrp "test"."autogen"

var output = stream
|from()
.measurement('collection1')
.groupBy(*)
|window()
.period(1m)
.every(1m)

var output2 = stream
|from()
.measurement('collection2')
.groupBy()
|window()
.period(1m)
.every(1m)

var intf_name = output
|where(lambda: "output".'receiving-interface-name' == "output2".'interface')

var result = '''select "mtu" from "collection2" where "interface-name"=='intf_name''''

|alert()
.id('/jobs:jobs/telemetry-measurement:measurement/measurement=test/query=test')
.crit(lambda: 1 == 1)
.log('/tmp/out.tmp')

In the above script, Below statement is correct?

var result = '''select "mtu" from "collection2" where "interface-name"=='intf_name''''

we are storing the result in one variable, and comparing with one or more fields. This is compressed version of real scenario. It can have multiple conditions, thats why we are storing in a variable and then comparing wherever it is required.

Regards,

Rajesh

Closing this topic, as it appears to be a duplicate of How to compare the current series of data with previous series using kapacitor (tick script).