Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested IF Statement

Is it possible to nest an IF statement within another IF statement? So for example for the below... would that be the best way of doing things?


If(Len(NetSalesValue) > 9, 0, NetSalesValue)  as [Invoice Value],

if(NetSalesValue < 0, NetSalesValue, 0) as [Credit Value],

I would like to still apply the Invoice Value IF to the Credit Value.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi Lewis,

Yes, that's possible indeed and should work just fine in the script. Check this syntax:

If(

  If(Len(NetSalesValue) > 9, 0,NetSalesValue) < 0,

    NetSalesValue, 0) as [Credit Value],

Hope that helps.

Miguel

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hi Lewis,

Yes, that's possible indeed and should work just fine in the script. Check this syntax:

If(

  If(Len(NetSalesValue) > 9, 0,NetSalesValue) < 0,

    NetSalesValue, 0) as [Credit Value],

Hope that helps.

Miguel

Not applicable
Author

I think the problem you have is that you have called the NetSalesValue twice... try the formula below..

if(If(Len(NetSalesValue) > 9, 0, NetSalesValue)< 0, NetSalesValue, 0) as [Credit Value],

Or you could use this.

If(Len(netSalesValue)>9 and NetSalesValue<0, NetSalesValue,0) as [Credit Value],

I Hope this helps

Ali

Not applicable
Author

Thanks again Miguel, thats perfect and works a treat!