# How to log and graph a variable only on specific conditions (non-periodic Tag Historian)

**URL:** <https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149>\
**Category:** Ignition\
**Tags:** vision, ignition81\
**Created:** [July 4, 2025, 8:53pm UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149 "2025-07-04T20:53:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![maury.sanchez](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@maury.sanchez](https://forum.inductiveautomation.com/u/maury.sanchez)\
**Post date:** [July 4, 2025, 8:53pm UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149/1 "2025-07-04T20:53:56Z")

</div>

Hi all,

I’m using Ignition 8.1.48 with the Vision, Tag Historian and SQL Brigde modules, and I need help setting up historical logging for a tag only when a certain condition is true — for example, when a tag is 1..

Here’s what I need to do:

- Start logging a tag value only while a condition is true.
- Stop logging when the condition goes false.
- Plot the logged values later in an Easy Chart.
- Make sure the data is stored in the database, not just in memory.

I don’t want the tag to be logged continuously. I only want to store values while something is happening, like when a tag is ON, and stop when that tag is OFF.

What’s the best way to approach this in **Vision**?

Things I’ve considered:

- Enabling/disabling the historian dynamically (not sure if that’s possible in Vision).
- Using a memory tag with history enabled and writing to it conditionally.
- Using `system.tag.storeTagHistory()` to manually push values into the historian.

Any examples or recommendations would be much appreciated!

Thanks!

---

<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:** [July 4, 2025, 9:57pm UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149/2 "2025-07-04T21:57:39Z")

</div>

The tag historian doesn't directly support this.

The SQL Bridge module is designed to do exactly this, with a suitable trigger and period.

You can also use a gateway timer event script to do this.

---

<div class="post-metadata">

**Author:** ![Rick\_de\_Man](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rick_de_man/32/75670_2.png) [@Rick\_de\_Man](https://forum.inductiveautomation.com/u/Rick_de_Man)\
**Post date:** [July 5, 2025, 5:55am UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149/3 "2025-07-05T05:55:57Z")

</div>

What if we toggle the Enabled property for Historian using scripting?

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [July 5, 2025, 1:32pm UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149/4 "2025-07-05T13:32:41Z")

</div>

If you're okay with the tag not updating at all when the condition is not met, you could utilize a driven tag group, configured so that the tag only scans (and stores history) based on your condition. Follow the [Driven Tag Group Examples](https://www.docs.inductiveautomation.com/docs/8.1/platform/tags/tag-groups/driven-tag-group-example), except set the `Rate` to 0 seconds.

---

<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:** [July 5, 2025, 3:46pm UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149/5 "2025-07-05T15:46:40Z")

</div>

> [@Rick\_de\_Man](#):
>
> What if we toggle the Enabled property?

That should work, with some changeover delay. But note that is a tag **configuration** property, and there is overhead and internal DB churn for doing that.

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [July 5, 2025, 4:12pm UTC](https://forum.inductiveautomation.com/t/how-to-log-and-graph-a-variable-only-on-specific-conditions-non-periodic-tag-historian/108149/6 "2025-07-05T16:12:44Z")

</div>

Seems to me it woud be better to do this at the tag value source level. If it's a PLC, clear the tag that's historized when the condition is false.
