Need clarification for Stream Tickscript Joining two measurement for two difference periods


What is the best way to alerts where i have two measurements

  1. M1
  2. M2
    M1 collects data every 15 minute (so one row every 15 minutes) and M2 every minutes.

Currently i tried stream tickscript and joined to get the calculation from.

For “M1” i have used the following
And for “M2”

I have also used align and Tolerence but and storing the alerts in Influxdb.
But i see a difference of 30 minutes between two alerts, why is that?
Is it because since measurement “M1” has collection interval of 15 minutes, it will only consider new data-points and therefore using .every(5m) will not work as it will not have new data-points for the join to process further and it will wait until it gets new data-points.

What are the other ways you would recommend, batch tickscripts, etc ?

I used tolerence from 30m to 15m and the difference has been reduced but still it is over or around 15 min.
Any other suggestions?