# Writing multiple 'if' statements for an expression tag

**URL:** <https://forum.inductiveautomation.com/t/writing-multiple-if-statements-for-an-expression-tag/5558>\
**Category:** Ignition\
**Created:** [December 11, 2012, 1:48pm UTC](https://forum.inductiveautomation.com/t/writing-multiple-if-statements-for-an-expression-tag/5558 "2012-12-11T13:48:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viggi](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@Viggi](https://forum.inductiveautomation.com/u/Viggi)\
**Post date:** [December 11, 2012, 1:48pm UTC](https://forum.inductiveautomation.com/t/writing-multiple-if-statements-for-an-expression-tag/5558/1 "2012-12-11T13:48:41Z")

</div>

I have a UDT with 2 memory tags and 1 OPC tag and 1 expression tag. Let me call those tags  
A1, A2, S1, P1. A1, A2 are two user defined values. S1 is the OPC tag and P1 is the expression tag.  
I could make one expression which is as follows

```auto
if(S1 > A1 && S1 < A2,1,0)  
```

by which I can get the expression tag, P1 =1 for a value of S1 between A1 and A2.  
Now I would like to have the expression tag, P1 change its value if S1 is less than A1.  
So I write the code

`if(S1 > A1 && S1 < A2,1,0)
if(S1 < A1 ,2,0)`

I get an error when i write two lines of ‘if’ statement.  
when i write a single ‘if’ statement there is no error.

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [December 11, 2012, 3:16pm UTC](https://forum.inductiveautomation.com/t/writing-multiple-if-statements-for-an-expression-tag/5558/2 "2012-12-11T15:16:37Z")

</div>

I think you want:

`if(S1 > A1 && S1 < A2,1,if(S1 < A1 ,2,0))`You can nest another if in the true or false case.
