# 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:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [November 9, 2022, 4:22am UTC](https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272/1 "2022-11-09T04:22:09Z")

</div>

Hi,  
I have an expression tag and sometimes the quality of this tag becomes 'Uncertain Initial Value'.  
Expression:`if (!{[.]LossFlag},coalesce({[.]TotLoss},0),coalesce({[.]PrevLoss}, 0)) * toInt(!{[.]ShiftChangeCheck})`

Quality becomes good only when i restart the tag.

Any suggestions to overcome this?

---

<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.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [November 9, 2022, 9:40am UTC](https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272/3 "2022-11-09T09:40:36Z")

</div>

Yes I do remember.  
I tried the same. but since I wish to display in live mode, i went with the expression pov.  
I am facing the similar error sometimes in other tags too at situations like db restart/gateway restart.  
So is there any way to handle this?

---

<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:43am UTC](https://forum.inductiveautomation.com/t/overcome-uncertain-initial-value-quality-of-expression-tag/66272/4 "2022-11-09T09:43:43Z")

</div>

I'm guessing this happens because the expression is referencing tags that don't yet have reliable values.  
So either change the expression to handle this case, or make a change to the referenced tags to avoid unreliable values.

We'll need more details about those tags to help you more accurately.
