# Expression tag error

**URL:** <https://forum.inductiveautomation.com/t/expression-tag-error/45570>\
**Category:** Ignition\
**Created:** [April 14, 2021, 6:17am UTC](https://forum.inductiveautomation.com/t/expression-tag-error/45570 "2021-04-14T06:17:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnaik](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nnaik](https://forum.inductiveautomation.com/u/nnaik)\
**Post date:** [April 14, 2021, 6:17am UTC](https://forum.inductiveautomation.com/t/expression-tag-error/45570/1 "2021-04-14T06:17:46Z")

</div>

Hello,  
I have created an expression tag to increment a value every second based on State tag and want to retain the value.  
My expression is  
if({[.]State}=1,{[.]ActualTime}+1,{[.]ActualTime}+0)

If state = 1 increment actual time tag if State tag \<\> 0 keep actual time last value  
but it gives error Expression left operand is null.  
but if i write the expression as if({[.]State}=1,{[.]ActualTime}+1,0)  
the value increments but as soon as state tag \<\> 0 value becomes zero.  
Any help appreciated.

Regards,  
Narayan

---

<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:** [April 14, 2021, 12:33pm UTC](https://forum.inductiveautomation.com/t/expression-tag-error/45570/2 "2021-04-14T12:33:46Z")

</div>

Wrap the whole thing in a `try()` expression function, and its fallback value will be your startup value. If you also want the count to survive expression start, you’ll need to use something else. Also, if you count is supposed to represent time, keep in mind that scan classes/tag group paces are **not** very precise. If you need to track time, record and do math on timestamps.

---

<div class="post-metadata">

**Author:** ![nnaik](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nnaik](https://forum.inductiveautomation.com/u/nnaik)\
**Post date:** [April 14, 2021, 2:46pm UTC](https://forum.inductiveautomation.com/t/expression-tag-error/45570/3 "2021-04-14T14:46:21Z")

</div>

Thank you sir, this solution helped.  
now my expression is  
try(if({[.]State}=1,{[.]ActualTime}+1,{[.]ActualTime}+0),0)
