# Expression History tag not Holding Value

**URL:** <https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting, database\
**Created:** [September 15, 2023, 2:06pm UTC](https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217 "2023-09-15T14:06:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Craig\_Simpson](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@Craig\_Simpson](https://forum.inductiveautomation.com/u/Craig_Simpson)\
**Post date:** [September 15, 2023, 2:06pm UTC](https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217/1 "2023-09-15T14:06:27Z")

</div>

Hi All,

I am having some anomalies that are causing me problems in my pressure test cell simulator project. Probably due to my lack of Ignition knowledge etc. This is in Vision 8.1, test VM with trial license.

To simulate pressure rising and falling in tags I have created 2 Gateway scripts; one for incrementing a value and one for decreasing a value, both at @ 200ms.  
In my project I am using expression tags for pump and product pressure, which on page load I am scripting the change of the expression to be a float of 0.0.  
These two tags have history in the default SQLdb.

When we start the test I take a stamped value of the current increasing tag value and write it to a tag, to effectively make a zero point.  
I then change the pump pressure tag's expression to  
`pumpExpression = "{[.]gwTimerInc}-{[.]gwTimerStamp}" `  
This works well and simulates rising pressure with a pump, which is plotted in an Easy Chart. When the test is finished I write the tag's expression back to "0.0".

However, after a simulated test I am noticing that the value of the product pressure tag bounces around, even with the expression firmly locked at "0.0"? I just cannot see what is driving this as the expression does not change? Any help would be appreciated.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf1a07c83393efdac0a8b9c4e47fd11d3a1459cf.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/e/eebebad2a88cc9ba2c8a301380f0090990cf56ee.png)

---

<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:** [September 15, 2023, 2:38pm UTC](https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217/2 "2023-09-15T14:38:38Z")

</div>

Instead of writing a new expression, use a single expression to handle the logic. Something like (if I understand your tag structure correctly):

```auto
if({[.]testActive,
   {[.]gwTimerInc}-{[.]gwTimerStamp},
   0)

```

---

<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:** [September 15, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217/3 "2023-09-15T15:58:43Z")

</div>

You might find the `ramp()` expression function from my (free) [Simulation Aids](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-simulation-aids) module helpful.

---

<div class="post-metadata">

**Author:** ![Craig\_Simpson](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@Craig\_Simpson](https://forum.inductiveautomation.com/u/Craig_Simpson)\
**Post date:** [September 25, 2023, 8:33am UTC](https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217/4 "2023-09-25T08:33:21Z")

</div>

Thanks Jordan.  
Rather then force the expression to change there were more stable results by setting the expression to handle the data change scenarios. The tag ended up like -

```auto
//control product pressure
if({[.]testActive}&&{[.]productPressureInc}, {[.]pumpPress}*0.995
,if({[.]testActive}&&{[.]productPressureHold}, {[.]productPressStamp}
,if({[.]testActive}&&{[.]productPressureDec}, {[.]productPressStamp}-({[.]gwTimerDecStamp}-{[.]gwTimerDec})
,0.0
)))

```

But was successful.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Craig\_Simpson](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@Craig\_Simpson](https://forum.inductiveautomation.com/u/Craig_Simpson)\
**Post date:** [September 25, 2023, 8:34am UTC](https://forum.inductiveautomation.com/t/expression-history-tag-not-holding-value/79217/5 "2023-09-25T08:34:35Z")

</div>

Thank you. I have installed this module on the Gateway and have been using some of the tasty goodies in there!! 👍
