Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
Can you please help me to figure out what is wrong with below if condition?
Somehow its not giving expected results.
if(Type = 'XXX',if(Root <> 'Total', if(Match (Category,'8','1','2','33','35','3') and match(subtype,'20','21','23','20') ,
if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt , [Amount] * YYY , if(Type = 'XXX',if(Root = 'Total' , if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt, [Amount] * YYY)))))) as AAAA
Thanks
Hello,
Perhaps because there's any final ")" for your multiple "if" ?
Looks like few conditions are duplicated and doesn't make sense, as cdecluseau mentioned, one last ')' is missing.
Doesn't it look like this when remove duplicated condtions -
if(Type = 'XXX',
if(Root <> 'Total',
if(Match (Category,'8','1','2','33','35','3') and match(subtype,'20','21','23','20') ,
if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt ,
[Amount] * YYY
)
)
)
) as AAAA
Yes, it's seems there is a closing parenthesis missing.
Besides this, it seems that your second condition based on Root = 'Total' can't evaluate to True, because it's in the THEN branch for your first condition Root <> 'Total':
if(Type = 'XXX',
if(Root <> 'Total',
if(Match (Category,'8','1','2','33','35','3') and match(subtype,'20','21','23','20'),
if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt ,
[Amount] * YYY ,
if(Type = 'XXX',
if(Root = 'Total' ,
if([Date] >= IntialDate and [Date]<=FinalDate and [Amount] >= InitialAmt and [Amount] <= FinalAmt,
[Amount] * YYY
)
)
)
)
)
)
) /*missing Parenthesis added */ as AAAA
Thanks for reply.
Unfortunately still not getting expected results. Any alternative to if condition there?
Thanks
Well, without knowing what you want to achieve (AKA 'expected results' in combination with input values), it's hard to help without guessing around.
Hi,
Please find attached to the main question .It has example data in the script.
Thanks
Still not sure what you are trying to achieve.
Your Amt1 values does not match in the intervals given by InitialAmt and FinalAmt in your Calc table, that's why you don't get any Disc1 results.
Also take care to use an appropriate Date Format, so your date values show a numeric representation and you can use > or < for comparison.
I've changed some of your input Amt1 values to get the comparison with your limits working and guessed around what you might want to do.
Attached a sample that delivers something.