On the GO Warehouse sample. I would like to I would like to create a mutiple if statement like
If ([First of Month Day of the week] = 5) THEN
([Sales].[Time].[Time].[Day].[Day of the month]-
3)
IF ([First of Month Day of the week] = 6)THEN
([Sales].[Time].[Time].[Day].[Day of the month]-
4)
IF ([First of Month Day of the week] = 7) THEN
([Sales].[Time].[Time].[Day].[Day of the month]-
5)
ELSE
([Sales].[Time].[Time].[Day].[Day of the month])
But I am getting a parsing error. Please help me with the correct syntax. I am new to Report Studio.
Just add else in front of if except the first one:
If (xxx = xx) then ()
else if (uuu=uu) then ()
else if (......) then ()
else ....
I'm not sure if Suraj's suggestion will work (perhaps Cognos has made IF more flexible in Cognos8)...I've always found it necessary to enclose all 3 clauses in parentheses:
IF () THEN () ELSE ()
I used to have a lot of trouble with IF syntax, now I start them all by typing the above and then filling in the ()s.
almeids,
yes, even after else, we need () depending on data type.
for example, usually else null with integer data types doesn't need () but for others, it is required.
I was pointing to the major flaw in the original if syntax and that was missing 'else' before secondary if's.
thanks
hi
chk out this is working
If ([First of Month Day of the week] = 5) THEN
([Sales].[Time].[Time].[Day].[Day of the month]-
3)
else IF ([First of Month Day of the week] = 6)THEN
([Sales].[Time].[Time].[Day].[Day of the month]-
4)
else IF ([First of Month Day of the week] = 7) THEN
([Sales].[Time].[Time].[Day].[Day of the month]-
5)
ELSE
([Sales].[Time].[Time].[Day].[Day of the month])
and the syntax of if is if(condition) then(expression) else(expression) and if you try to use nested if then
if(condition)
then(expresion) else if(condition)
.........
else(expression)
hope this explanation will help you
Regards,
Jahnavi.