Writing multiple 'if' statements for an expression tag

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

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.

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.