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

Nested If

I am getting an error for the below code: Error in Expression, If takes 2-3 parameters.

if(Age>92,(Value * Age)/'365',Value))As New_Value

1 Solution

Accepted Solutions
Not applicable
Author

I am checking the same. The script now is showing no error and got executed. Now as sanshupop has mentioned above, i have to check if the logic of the expression is working correctly or not. Sure will keep you updated.

View solution in original post

9 Replies
Not applicable
Author

Hello,

Just by looking at it there are to many right-side brackets. However, since your title mentions nested if-statements, there might be another if-statement? If so, then it would be best to show that statement aswell.

Regards

Not applicable
Author

if(isnull([Start Date])=-1 or isnull([End Date])=-1 or Age<=92,Value,

if([Start Date]>[End Date],'99999'),

if(Age>92,(Value * Age)/'365',Value))As New_Value

Not applicable
Author

Seems to be a mixup with the brackets.

The right way should be:

if(isnull([Start Date])=-1 or isnull([End Date])=-1 or Age<=92,Value,

if([Start Date]>[End Date],'99999',

if(Age>92,(Value * Age)/'365',Value))) As New_Value

SunilChauhan
Champion
Champion

try this

if(isnull([Start Date])=-1 or isnull([End Date])=-1 or Age<=92,Value,

if([Start Date]>[End Date],99999),

if(Age>92,(Value * Age)/365,Value))As New_Value

hope this helps

Sunil Chauhan
Not applicable
Author

thank you

Not applicable
Author

I dont think that will work. The if-statements need to be nested, that is the next if-statements need to be inside one of the logical consequences of the previous statement.

Ex:

     if(condition, then , if(condition, then))

not

     if(condition, then),if(condition,then) since qlikview will see the two statement as seperated and the whole expression will be seen as illogical.

SunilChauhan
Champion
Champion

mark it correct so that  we can understand that issue is closed .

Sunil Chauhan
Not applicable
Author

I am checking the same. The script now is showing no error and got executed. Now as sanshupop has mentioned above, i have to check if the logic of the expression is working correctly or not. Sure will keep you updated.

Not applicable
Author

Logic is working correctly with the same corrected expression. Thanks for the help...