# How to set an expression tag to not change on false

**URL:** <https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983>\
**Category:** Ignition\
**Created:** [October 15, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983 "2021-10-15T13:11:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/1 "2021-10-15T13:11:29Z")

</div>

if true, I change the value, but on false, I don’t want to change the value.  
I am not sure how to make it not change though.

Throws an error with “if (condition ,true)” without the false condition.  
Throws an error if I put value or if I put it’s own tag.

---

<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:** [October 15, 2021, 2:06pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/2 "2021-10-15T14:06:42Z")

</div>

You can’t do this with an expression. It will have to be done in scripting.

You will need two tags. One to hold the raw value, and one to write the value to if the conditions are met. A tag script can handle the rest.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/d/8dbe0d1d7964e40710dc962a92a2ebb456bdd19f.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/d/8d78da2d6be24a94bdef8581a806a0c49949ebfa.png)

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

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [October 15, 2021, 2:19pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/3 "2021-10-15T14:19:09Z")

</div>

Can’t you just set it to itself on the false condition?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/a/4a543aa876fe3e574e78bcb191fb640c50255243.png)

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

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

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 2:21pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/4 "2021-10-15T14:21:45Z")

</div>

I get an error if I set the tag to itself in the false case.

Seems really odd that in an expression tag logical IF, the false case is required.

But yah, in the script, I say if x write y to z  
I don’t like that the script has to be on the raw data side rather than the tag that I am working on.  
If someone wants to back-trace where it is written from, they have to check all the other spots.

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [October 15, 2021, 2:32pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/5 "2021-10-15T14:32:31Z")

</div>

Hmmm… yeah expression tags don’t let you do that. It does work partly but you can’t change the value of the expression tag directly. Jordan’s answer is the correct way.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 15, 2021, 2:33pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/6 "2021-10-15T14:33:00Z")

</div>

> [@zacharyw.larson](#):
>
> I get an error if I set the tag to itself in the false case.
> 
> Seems really odd that in an expression tag logical IF, the false case is required.

Why is that odd? Also, what error, I did what @Duffanator suggested and it works just fine.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 15, 2021, 2:34pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/7 "2021-10-15T14:34:31Z")

</div>

Couldn’t you also use a [derived tag](https://docs.inductiveautomation.com/display/DOC81/Types+of+Tags#TypesofTags-DerivedTags) for this?

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 2:46pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/8 "2021-10-15T14:46:52Z")

</div>

how do you mean?  
don’t those use expression language too?

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 2:48pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/9 "2021-10-15T14:48:21Z")

</div>

for clarification  
`if (rawTag<1000,rawTag,thisTag)`  
throws an error for me.

`if (rawTag<1000,rawTag)`  
also throws an error for me, and this is the one that seems odd to me that it throws an error  
I expected this to work.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 15, 2021, 3:02pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/10 "2021-10-15T15:02:37Z")

</div>

Why would you expect the latter to work?  
Ignition’s expression language _must_ return a value, by definition. An `if` with no `else` is an incomplete statement.

In a derived tag, you could use `if({otherTag} < 1000, {value}, {source})` to discard incoming writes based on some other tag.  
However, if that’s what your actual expression is, then it really seems like you might just need clamping and/or scaling: [Tag Scaling Properties - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Tag+Scaling+Properties)

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 3:13pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/11 "2021-10-15T15:13:24Z")

</div>

Thanks  
I didn’t know I could specify the source in that.

In scripting and other languages I program in, I can typically write  
`if(condition,true)`

Or `if condition then x` I think expression language and excel are the only ones that I have seen a requirement for a false condition.

I mean that personal previous experiences caused me to think I wouldn’t be required to have a false or else.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 15, 2021, 3:15pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/12 "2021-10-15T15:15:19Z")

</div>

Yeah, that’s because Excel formulas are also an expression language. There’s no context or variables; it’s just a stack of operations to execute.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 3:28pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/13 "2021-10-15T15:28:26Z")

</div>

I thought I understood this, but I don’t

So source is the path to the raw tag

value is the current value excluding the source?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 15, 2021, 3:30pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/14 "2021-10-15T15:30:34Z")

</div>

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

Derived tags are ‘special’, and set up the read and write expressions with some context (specifically to avoid the problem/limitation of the expression language).

---

<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:** [October 15, 2021, 5:15pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/15 "2021-10-15T17:15:49Z")

</div>

> [@zacharyw.larson](#):
>
> In scripting and other languages I program in, I can typically write  
> `if(condition,true)`

That's a script statement, not an expression. Expressions in every programming language I know must yield a value.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [October 15, 2021, 5:32pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/16 "2021-10-15T17:32:58Z")

</div>

I am an electrical engineer. Forgive me. I took programming for non-believers.

edit  
I meant to excuse myself and be honest about not knowing that “Expression Language” was a whole subset of programming languages. I thought it was another programming language unto itself, and as unique as Java, Codesys, or Python. I had thought someone had decided to make Expression Language that certain way.

---

<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:** [October 15, 2021, 5:39pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/17 "2021-10-15T17:39:25Z")

</div>

I am also an electrical engineer. IMNSHO, engineer \> programmer, so I expect you can handle this. (:

---

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [October 15, 2021, 5:45pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/18 "2021-10-15T17:45:54Z")

</div>

That’s going to rile some people up… 🤣

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 15, 2021, 5:48pm UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/19 "2021-10-15T17:48:03Z")

</div>

As a programmer: Y’all are wizards 🙂

---

<div class="post-metadata">

**Author:** ![jeffrey.ashie](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jeffrey.ashie](https://forum.inductiveautomation.com/u/jeffrey.ashie)\
**Post date:** [October 21, 2021, 11:34am UTC](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983/20 "2021-10-21T11:34:00Z")

</div>

you cant be both 😉

[Next page](https://forum.inductiveautomation.com/t/how-to-set-an-expression-tag-to-not-change-on-false/51983.md?page=2)
