# Calculated tags

**URL:** <https://forum.inductiveautomation.com/t/calculated-tags/2628>\
**Category:** Ignition\
**Created:** [February 10, 2011, 11:56pm UTC](https://forum.inductiveautomation.com/t/calculated-tags/2628 "2011-02-10T23:56:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [February 10, 2011, 11:56pm UTC](https://forum.inductiveautomation.com/t/calculated-tags/2628/1 "2011-02-10T23:56:39Z")

</div>

I know that you can add like an avg of a tag onto a trend using the calculated tag… but is there a way to take multiple tags and get a sum of them and display that on a trend?

for instance, I have 3 pressures, id like to be able to take all 3 of those and add them up and have them display the sum of the pressures as a pen on a trend, which could then be compared to another tag on a trend.

this would have to be done dynamically, not something that I would have to go into the designer to do.

---

<div class="post-metadata">

**Author:** ![Henry](https://avatars.discourse-cdn.com/v4/letter/h/df705f/32.png) [@Henry](https://forum.inductiveautomation.com/u/Henry)\
**Post date:** [February 11, 2011, 12:31am UTC](https://forum.inductiveautomation.com/t/calculated-tags/2628/2 "2011-02-11T00:31:44Z")

</div>

In the SQL tags browser  
Right click\newtag\DB tag  
Then on the bottom left corner use Expression/SQL

Here is one of mine that sums flow rates  
{GENERATOR/LOS\_COCHES\_FLOW}+{DIST/BALL\_PS/BALL\_GRAVITY\_FLOW}+{DIST\_WLAN/PADRE\_6/PADRE6\_FLOW\_MGD}

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [February 11, 2011, 12:42am UTC](https://forum.inductiveautomation.com/t/calculated-tags/2628/3 "2011-02-11T00:42:44Z")

</div>

Yeah I know about doing it that way… I need something that I can do dynamically without having to build a tag for each instance. like if I could query the trend chart some kind of way and place that on a tag somehow.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [February 11, 2011, 2:07am UTC](https://forum.inductiveautomation.com/t/calculated-tags/2628/4 "2011-02-11T02:07:28Z")

</div>

Now your leaving the easy and entering the custom made area. ( Where the fun is 😈 )

Behind the scenes the graphing chart is calling system.tag.queryTagHistory  
You can call this function yourself with all the source tags and then loop through the retured dataset doing the required math to create a new dataset which you then graph on a generic graphing component.

If your really adventurous, you can do something like I did [here](http://www.inductiveautomation.com/forum/viewtopic.php?f=81&t=6060) except for the tags you want. Doing it that way would allow you to put the calculation into the query so the database does the hard work. However, the system.tag.queryTagHistory function does a bunch more stuff to fill in blanks and check status and filter out bad data etc.
