# Can a Expression Tag Reference itself

**URL:** <https://forum.inductiveautomation.com/t/can-a-expression-tag-reference-itself/101335>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [January 24, 2025, 10:01am UTC](https://forum.inductiveautomation.com/t/can-a-expression-tag-reference-itself/101335 "2025-01-24T10:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [January 24, 2025, 10:01am UTC](https://forum.inductiveautomation.com/t/can-a-expression-tag-reference-itself/101335/1 "2025-01-24T10:01:52Z")

</div>

I have a tag1 and a tag\_result.

I only want to save the first positive value that I encounter from tag1.  
Like this:

| tag1 | tag\_result |
| --- | --- |
| -100 | 0 |
| -200 | 0 |
| 100 | 100 |
| 200 | 100 |
| -100 | 0 |
| 200 | 200 |
| 300 | 200 |
| 200 | 200 |
| 100 | 200 |
| -200 | 0 |

I tried to do this:

```python
1 if(
2 {[.]tag1} < 0,
3 0,
4 if(
5 {[.]tag_result} > 0, # already a value saved
6 {[.]tag_result}, # no change
7 {[.]tag1}
8 )
9 )

```

However, line 6 is given a `error_confg`.  
Any idea of why this could be?  
As a temporal solution I'm using a script when ValueChanged in `tag1`

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [January 24, 2025, 10:33am UTC](https://forum.inductiveautomation.com/t/can-a-expression-tag-reference-itself/101335/2 "2025-01-24T10:33:48Z")

</div>

Maybe try

```python
{
    if (
        self < 0, # Use 'self' instead of tag1
        0,
        if (
            {[.]tag_result} > 0, # Already a value saved
            {[.]tag_result}, # No change
            self # Use 'self' instead of tag1
        )
    )
}

```

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [January 24, 2025, 10:43am UTC](https://forum.inductiveautomation.com/t/can-a-expression-tag-reference-itself/101335/3 "2025-01-24T10:43:42Z")

</div>

Doesn't work. We are at expression language so is not the same as python sadly

---

<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:** [January 24, 2025, 10:55am UTC](https://forum.inductiveautomation.com/t/can-a-expression-tag-reference-itself/101335/4 "2025-01-24T10:55:39Z")

</div>

Expression can't write to istelf. Your tag script is the best solution.

If you have a lot of those, however, consider using a gateway tag change script.
