# Tag Value Derived From Historian

**URL:** <https://forum.inductiveautomation.com/t/tag-value-derived-from-historian/57439>\
**Category:** Ignition\
**Created:** [March 21, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/tag-value-derived-from-historian/57439 "2022-03-21T21:53:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![levi.jacobs](https://avatars.discourse-cdn.com/v4/letter/l/dec6dc/32.png) [@levi.jacobs](https://forum.inductiveautomation.com/u/levi.jacobs)\
**Post date:** [March 21, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/tag-value-derived-from-historian/57439/1 "2022-03-21T21:53:17Z")

</div>

I’m trying to figure out the best way to access tag history in a derived/reference/expression tag. For example, say tagA is an opc tag and it’s storing history. I want the value of tagB to be calculated from tagA’s history (tagB might be the average of tagA over 1 week, the exact value of tagA 24 hrs ago, etc.).

The only way I can think of accomplishing this is to make tagB an expression tag that uses the Advanced/RunScript function that runs a jython script that uses the system.tag.queryTagHistory function. I’m worried this method will be too inefficient to use on a large scale (say 1000’s of tagB’s).

Does anyone have a recommendation?

Thanks,  
Levi

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [March 21, 2022, 11:03pm UTC](https://forum.inductiveautomation.com/t/tag-value-derived-from-historian/57439/2 "2022-03-21T23:03:03Z")

</div>

What are you going to attach to `tagB`? Offhand, I can't think of an application that wouldn't be better to query the

> [@levi.jacobs](#):
>
> the average of tagA over 1 week, the exact value of tagA 24 hrs ago, etc.

or whatever else right where you want to use it.
