# Holding state in an expression tag

**URL:** <https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837>\
**Category:** Ignition\
**Created:** [January 15, 2014, 6:38am UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837 "2014-01-15T06:38:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![howarddpsg](https://avatars.discourse-cdn.com/v4/letter/h/ecc23a/32.png) [@howarddpsg](https://forum.inductiveautomation.com/u/howarddpsg)\
**Post date:** [January 15, 2014, 6:38am UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/1 "2014-01-15T06:38:56Z")

</div>

I want to hold the current value in an expression tag if none of my expressions are true. how do I do this?  
Thanks

---

<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:** [January 15, 2014, 12:25pm UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/2 "2014-01-15T12:25:40Z")

</div>

show us an example of what you are trying to do.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 15, 2014, 1:25pm UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/3 "2014-01-15T13:25:15Z")

</div>

An example would be great.

At first blush, a it may be easier set this up in a transaction group. I had briefly mentioned them in your other post. While most think about transaction groups as being used exclusively with the database, in truth, you can also use them to manipulate tags. ![8)](https://us1.discourse-cdn.com/inductiveautomation/original/1X/587d7fe0d6822f36e81815ab06aa7164e9d2e057.gif "Cool")

---

<div class="post-metadata">

**Author:** ![howarddpsg](https://avatars.discourse-cdn.com/v4/letter/h/ecc23a/32.png) [@howarddpsg](https://forum.inductiveautomation.com/u/howarddpsg)\
**Post date:** [January 16, 2014, 12:11am UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/4 "2014-01-16T00:11:45Z")

</div>

don’t have an example yet. basically, trying to show a value based on time of day. and when time of day expression is not true. I want to hold the last value when the expression was true.  
basically an if statement except no false return. if its false just hold what ya got.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [January 16, 2014, 12:54am UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/5 "2014-01-16T00:54:09Z")

</div>

Just make the property expression refer to itself if the condition is false.

Say you have a component property at: rootContainer.label.text

Then use this expression:

```auto
if(some condition, some value, {Root Container.Label.text})
```

If the condition is false then the current property value does not change.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [January 16, 2014, 12:58am UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/6 "2014-01-16T00:58:12Z")

</div>

Here is an example with a Numeric Text Field. It will only display even seconds – holding on to the last even number when the current second is odd:

```auto
if(dateExtract(now(),"second") % 2 = 0,dateExtract(now(),"second"),
{Root Container.Numeric Text Field.intValue}) 
```

I put the above expression on the Root Container.Numeric Text Field.intValue property.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [January 16, 2014, 1:07am UTC](https://forum.inductiveautomation.com/t/holding-state-in-an-expression-tag/7837/7 "2014-01-16T01:07:31Z")

</div>

I see you specifically asked about doing this in an expression SQLTag.

The same method works in an expression tag. Refer the tag to itself to hold the current value if your condition is false. Let’s say we have a tag at the path “test”.

This expression works in the tag:

```auto
if(dateExtract(now(),"second") % 2 = 0,dateExtract(now(),"second"),
{[~]test}) 
```
