# Querying Historical Data Values

**URL:** <https://forum.inductiveautomation.com/t/querying-historical-data-values/106071>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [May 8, 2025, 7:15pm UTC](https://forum.inductiveautomation.com/t/querying-historical-data-values/106071 "2025-05-08T19:15:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob.leonard](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@jacob.leonard](https://forum.inductiveautomation.com/u/jacob.leonard)\
**Post date:** [May 8, 2025, 7:15pm UTC](https://forum.inductiveautomation.com/t/querying-historical-data-values/106071/1 "2025-05-08T19:15:16Z")

</div>

TLDR:  
Is there a function that can pull the last state change of a bool tag? I have a bool tag and on the falling edge of the tag, i want to pull the datetime it changed to the on state (Its last rising edge).

I guess if its a bool tag, and i set the max time between samples to 10 years, then it would be the next to last data point...

Details:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b67d5b9321df80a2399a395c383f57d4c96ee0d0.png)  
I am trying to automatically audit a furnace run. It needs to not heat too fast and stay at a temp for at least a certain time. As you can see from the graph, they are also running different parts in the same furnace. The first step is to segment out the historical data into different runs data.

Bonus points if you can figure out how to send it to a report each time the run ends (the run bit goes low)

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [May 8, 2025, 9:35pm UTC](https://forum.inductiveautomation.com/t/querying-historical-data-values/106071/2 "2025-05-08T21:35:40Z")

</div>

Sounds like a Tag change Script (or Gateway Events level) can work:

> **[Tag Event Scripts | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/tags/tag-event-scripts)**
>
> Scripts can be attached to tags. When you edit a tag, you can navigate to the Tag Events section and click on the Edit icon to see a list of all of the available events. Those events are

You have access to the incoming and previous Qualified Values (includes timestamps), since you are dealing with a Boolean this would lead to the currentValue having the 0 while previousValue gets the 1 every time it goes False. Executing a report when a tag changes is also done this way using [system.report.executeAndDistribute()](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-report/system-report-executeAndDistribute).

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [June 19, 2025, 2:28am UTC](https://forum.inductiveautomation.com/t/querying-historical-data-values/106071/3 "2025-06-19T02:28:36Z")

</div>

what did you end up doing?
