# Detect a changing value

**URL:** <https://forum.inductiveautomation.com/t/detect-a-changing-value/17175>\
**Category:** Ignition\
**Tags:** database\
**Created:** [February 28, 2018, 10:50pm UTC](https://forum.inductiveautomation.com/t/detect-a-changing-value/17175 "2018-02-28T22:50:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uttara17](https://avatars.discourse-cdn.com/v4/letter/u/838e76/32.png) [@uttara17](https://forum.inductiveautomation.com/u/uttara17)\
**Post date:** [February 28, 2018, 10:50pm UTC](https://forum.inductiveautomation.com/t/detect-a-changing-value/17175/1 "2018-02-28T22:50:52Z")

</div>

I have a tag whose value continuously increases/ decreases in real time. How can I detect if the value is increasing or decreasing and then display it?

---

<div class="post-metadata">

**Author:** ![Claus\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Claus\_Nielsen](https://forum.inductiveautomation.com/u/Claus_Nielsen)\
**Post date:** [March 1, 2018, 6:57am UTC](https://forum.inductiveautomation.com/t/detect-a-changing-value/17175/2 "2018-03-01T06:57:07Z")

</div>

Depending on a lot of things, a quick way would be something like this.  
Create two memory tags, one named Increasing and one Decreasing, both of boolean type, then in the real time tags value changed event script add the following code.

```auto
if initialChange:
	return

increasing = currentValue.value > previousValue.value

writes = {"Increasing" : increasing,
	      "Decreasing" : not increasing}

system.tag.writeAll(writes.keys(), writes.values())

```

If the realtime tag ‘flickers’ a lot, this might need some adjustment though. Also, if the tag is steady, the last increasing or decreasing state is held
