# Expression Statement if not 0

**URL:** <https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790>\
**Category:** Ignition\
**Created:** [January 4, 2024, 2:51pm UTC](https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790 "2024-01-04T14:51:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [January 4, 2024, 2:51pm UTC](https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790/1 "2024-01-04T14:51:30Z")

</div>

I am trying to write an expression statement that is taking 2 machines production rate minus there goal. The problem is that when one of the machines is off, its production rate is 0, which skews the numbers. This is my current statement:

```auto
{[default]E289/E289/Analytics/Current/Shift Production at Current}+{[default]E293/E293/Analytics/Current/Shift Production at Current})-({[default]E231/E231/Analytics/Current/Shift Goal at Current}+{[default]E233/E233/Analytics/Current/Shift Goal at Current}

```

Is there some way that I could exclude a machines "Shift Goal at Current" number if the "Shift Production at Current" number is 0?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 4, 2024, 3:33pm UTC](https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790/2 "2024-01-04T15:33:34Z")

</div>

You can use the `if()` expression to check the value and return one of two equations depending on the result.

```auto
if({Shift Production at Current} > 0, equation including machine, equation excluding machine)

```

[https://docs.inductiveautomation.com/display/DOC81/if](https://docs.inductiveautomation.com/display/DOC81/if)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 4, 2024, 4:06pm UTC](https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790/3 "2024-01-04T16:06:13Z")

</div>

Your post mentions two machines but your post seems to reference four machines, E231, E233, E289 and E293. Also you are missing the opening and closing `( )`. Anyway, the full expression would be something like:

```auto
if(
    {[default]E289/E289/Analytics/Current/Shift Production at Current} > 0,
    {[default]E289/E289/Analytics/Current/Shift Production at Current}
    + {[default]E231/E231/Analytics/Current/Shift Goal at Current},
    0
)
+
if(
    {[default]E293/E293/Analytics/Current/Shift Production at Current} > 0,
    {[default]E293/E293/Analytics/Current/Shift Production at Current}
    - [default]E233/E233/Analytics/Current/Shift Goal at Current},
    0
)

```

Tips:

- Expressions generally ignore linebreaks, tabs and additional spaces so you can wrap your expressions as I have shown for readability.
- Add a space each side of the mathematical operators to let some air into your expressions (and equations in scripts). It makes them easier to read.

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [January 4, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790/4 "2024-01-04T16:58:19Z")

</div>

I tried this and it looks right, but I am getting this error  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/814badca5e815a41506ce6bd81dc543bd152b7ea.png)  
and it is referring to the \> symbol

```auto
+(if {[default]E236/E236/Analytics/Current/Shift Production at Current} > 0,{[default]E236/E236/Analytics/Current/Shift Goal at Current},0)

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [January 4, 2024, 5:01pm UTC](https://forum.inductiveautomation.com/t/expression-statement-if-not-0/83790/5 "2024-01-04T17:01:08Z")

</div>

Sorry I fixed it, I missed a parentheses..
