COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: lporter@wsutech.edu on 21 Apr 2020 03:43:22 PM

Title: if statement
Post by: lporter@wsutech.edu on 21 Apr 2020 03:43:22 PM
I don't understand why this doesn't work. I've used if-then-else before without a problem.

Address Type is VARCHAR2 (2) in an Oracle database. I want to create a sort key for these address types.

if ([ADDRESS_TYPE]='PA')
then 1
else
if ([ADDRESS_TYPE]='PR')
then 2
else
if ([ADDRESS_TYPE]='MA')
then 3
else 0

Parsing error before or near position 32 of "if ([ADDRESS_TYPE]='PA')
then 1"
Title: Re: if statement
Post by: bus_pass_man on 21 Apr 2020 04:19:58 PM
1. The syntax is  If (  ) then () else ()
2.  Consider using a case rather than a nested IF.  It is cleaner and clearer.