Skip to main content

User Guide

Stepped formula tags

All tags created through tag builder formulas are of the analog type, meaning they will be interpolated linearly. When our formula variables are discrete tags, this interpolation can lead to an output tag that does not look as expected.

The underlying issue is the mechanism by which our formulas are evaluated: a value is only calculated for timestamps where one of the input tags has a datapoint. Due to the often sparse nature of discrete tags, the points of the resulting formula tag are far apart. Interpolation between these then gives the undesirable effect.

We use the mechanism above to our advantage in this workaround. What we need to do is make sure our formula tag is always evaluated just before a stepped tag changes value. This means we need to give our formula an input variable that has a point just before our stepped tag does. Such a variable is easy to come by: we can simply take the formula tag itself, and give it a shift of -1s. This shifts the tag to the left, giving it a datapoint 1s before the original tag. Of course we do not want the shifted value of this tag to influence our calculation, so we can multiply it by 0. Repeat this process for every stepped tag in your formula, and your resulting tag will have the stepped appearance you were looking for.

stepped_formula.png