# Transform script only returns the else value

**URL:** <https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [March 1, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480 "2023-03-01T15:21:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dustin\_Castleberry](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Dustin\_Castleberry](https://forum.inductiveautomation.com/u/Dustin_Castleberry)\
**Post date:** [March 1, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480/1 "2023-03-01T15:21:53Z")

</div>

I am working on a simple script to just test the functionality of changing the text on a text box. The script runs but always returns nooo even when the tag value changes to a 1. What am I missing?

def transform(self, value, quality, timestamp):  
red = "yeah"  
grey = "nooo"  
return red if value is 1 else grey

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 1, 2023, 3:27pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480/2 "2023-03-01T15:27:28Z")

</div>

`is` doesn’t do what you think, use equality instead (`==`)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [March 1, 2023, 3:27pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480/3 "2023-03-01T15:27:32Z")

</div>

It looks like the tag is returning a boolean value,

```auto
return red if value else grey

```

A map transform may be a better fit for this

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [March 1, 2023, 3:28pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480/4 "2023-03-01T15:28:51Z")

</div>

```auto
return red if value is True else grey

```

also works

---

<div class="post-metadata">

**Author:** ![Dustin\_Castleberry](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@Dustin\_Castleberry](https://forum.inductiveautomation.com/u/Dustin_Castleberry)\
**Post date:** [March 1, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480/5 "2023-03-01T15:57:04Z")

</div>

Thanks. I am trying to improve my scripting. That's why I didn't use the map transform.

---

<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:** [March 1, 2023, 4:16pm UTC](https://forum.inductiveautomation.com/t/transform-script-only-returns-the-else-value/70480/6 "2023-03-01T16:16:28Z")

</div>

The gist about _why_ is that `is` is an _identity_ comparison (are these two objects _exactly the same_) while `==` is asking _each object_ whether it's equal to the other or not.

> <https://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is/133024#133024>

Python takes advantage of the fact that every object can be coerced to a boolean with its `if` statement, as well, hence the short form @dkhayes117 noted. That is, `if <expression>` is sufficient; there's no need to use `if <expression> == True`.

(Note that 'expression' here is the fundamental computer science term, nothing to do with Ignition's "expression" language. Confused yet? 🙂)
