There are a couple of good posts on comparisons of Gateway Events vs Tag Events on the forum, with (my) most-notable thread:
Taking above advice into consideration, and reading:
I would:
- Change 'this tag' to a dataset tag.
- Modify the existing script to append/insert the value to 'this tag' as a dataset.
then, either:
- Add another expression tag, utilizing mean(dataset, columnIndex) expression.
- Modify the existing script to calculate a new mean from the latest 12 values, and store that value (and last 11 historical calcs) in another column of the same dataset.