# Expression math using tags

**URL:** <https://forum.inductiveautomation.com/t/expression-math-using-tags/21112>\
**Category:** General Discussion\
**Created:** [November 28, 2018, 3:25pm UTC](https://forum.inductiveautomation.com/t/expression-math-using-tags/21112 "2018-11-28T15:25:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfoster](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@gfoster](https://forum.inductiveautomation.com/u/gfoster)\
**Post date:** [November 28, 2018, 3:25pm UTC](https://forum.inductiveautomation.com/t/expression-math-using-tags/21112/1 "2018-11-28T15:25:19Z")

</div>

Here is my expression to calculate a low limit:  
tag({Root Container.TITLE} + “\_Blend\_SP/FMB A Blend A SP”) - tag({Root Container.TITLE} + “\_Calc/SP Tolerance”)

FMB\_A SP\_A = 65  
SP Tolerance = 2  
result = 67  
Good

But  
Here is my expression to calculate the upper limit:  
tag({Root Container.TITLE} + “\_Blend\_SP/FMB A Blend A SP”) + tag({Root Container.TITLE} + “\_Calc/SP Tolerance”)

FMB\_A SP\_A = 65  
SP Tolerance = 2  
result = 65.02  
Not so good

What am i doing worng?

Thank you

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [November 28, 2018, 3:50pm UTC](https://forum.inductiveautomation.com/t/expression-math-using-tags/21112/2 "2018-11-28T15:50:06Z")

</div>

I’ve created the same situation on my project and it does the same thing 😨  
I don’t know what is going on here 😅 but I’ve fixed it like this:

```auto
toInt(tag({Root Container.TITLE} + "/BlendSP/FMB A Blend A SP")) + toInt(tag({Root Container.TITLE} + "/_Calc/SP Tolerance"))

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 28, 2018, 6:20pm UTC](https://forum.inductiveautomation.com/t/expression-math-using-tags/21112/3 "2018-11-28T18:20:49Z")

</div>

Y’all should wean yourself off of the tag() expression function. Use custom properties bound indirectly to your tags, then use those properties in your final expressions. This minimizes what executes as tag changes are distributed.

---

<div class="post-metadata">

**Author:** ![gfoster](https://avatars.discourse-cdn.com/v4/letter/g/e79b87/32.png) [@gfoster](https://forum.inductiveautomation.com/u/gfoster)\
**Post date:** [November 28, 2018, 6:43pm UTC](https://forum.inductiveautomation.com/t/expression-math-using-tags/21112/4 "2018-11-28T18:43:44Z")

</div>

That seems to be an excellent suggestion.  
I’m a newbie to object orientation. Suggestions like this one really help me better understand the new environment.

Is this just good OOP practice? or is there something worng with the tag() function?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 28, 2018, 9:24pm UTC](https://forum.inductiveautomation.com/t/expression-math-using-tags/21112/5 "2018-11-28T21:24:22Z")

</div>

> [@gfoster](#):
>
> Is this just good OOP practice? or is there something worng with the tag() function?

Bindings execute all-or-nothing. When using the tag() function, you have both indirects and tag values involved together, any change of which will cause the whole expression to re-execute. If you move the indirects to their own bindings, the final expression doesn't have to re-execute indirects that haven't changed.
