# Overcome Uncertain Initial Value quality of expression tag

**URL:** <https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272>\
**Category:** Ignition\
**Created:** [November 9, 2022, 4:22am UTC](https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272 "2022-11-09T04:22:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 9, 2022, 9:37am UTC](https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272/2 "2022-11-09T09:37:45Z")

</div>

I seem to remember this...  
I also remember that Phil provided a more robust solution:

> [@Counter like tag with cumulated value](https://forum.inductiveautomation.com/t/counter-like-tag-with-cumulated-value/65051/12):
>
> The reliable way to do this is to record state changes in an event table. Then use LEAD or LAG functions in the DB to get intervals per state, clipping to the start of shift. Sum those intervals while grouping by state. With an index on t\_stamp, your DB will calculate this blisteringly fast. Select state, sum(event\_duration) as duration From ( Select state, nextTS - clipped as event\_duration From ( Select state , case t\_stamp \< :shift\_start\_ts then :shift\_start\_ts else t\_stamp …

I warned you that this was only a little experiment I was doing for fun.

---

_[View the full topic](https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272)._
