COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: cognos4321 on 15 Dec 2017 12:54:17 PM

Title: If -then- else statement error
Post by: cognos4321 on 15 Dec 2017 12:54:17 PM
Hi ,

I am trying to use a detail filter on a report where 'pVersion' is a parameter and 'abc' , 'def' are attributes of a dimension in the cube. The statement below works fine.

If(?pVersion? = 'budget') then ( [abc]=1)
else ([def] =1)


But when I add another condition to the if statement it gives me 'XQE-PLN-0267'error

If(?pVersion? = 'budget' and ?pYear? =2017) then ( [abc]=1)
else ([def] =1)

I have tried using data items for version and year instead of parameter, working around with brackets also but nothing works.

Please advice what's wrong in the 2nd if statement.
I am working with cognos Analytics and  TM1 cubes as database.

Thank You.
Title: Re: If -then- else statement error
Post by: cognos4321 on 16 Dec 2017 11:03:45 AM
Please let me know if there is some other information needed.
I have tried replacing it with case statement also but nothing works.


Thanks.
Title: Re: If -then- else statement error
Post by: Kiran P on 16 Dec 2017 08:36:21 PM
Quote from: cognos4321 on 15 Dec 2017 12:54:17 PM
Hi ,

I am trying to use a detail filter on a report where 'pVersion' is a parameter and 'abc' , 'def' are attributes of a dimension in the cube. The statement below works fine.

If(?pVersion? = 'budget') then ( [abc]=1)
else ([def] =1)


But when I add another condition to the if statement it gives me 'XQE-PLN-0267'error

If(?pVersion? = 'budget' and ?pYear? =2017) then ( [abc]=1)
else ([def] =1)

I have tried using data items for version and year instead of parameter, working around with brackets also but nothing works.

Please advice what's wrong in the 2nd if statement.
I am working with cognos Analytics and  TM1 cubes as database.

Thank You.
Hi

I am not sure why there was an issue but you can try replacing it with nested if.

If(?pVersion? = 'budget' )

Then
        if(?pYear? =2017)
             then ( [abc]=1)
             else ([def] =1)

Else
([Def]=1)

Regards
Kiran

Sent from my ZUK Z2132 using Tapatalk

Title: Re: If -then- else statement error
Post by: cognos4321 on 18 Dec 2017 12:45:16 PM
Thanks for the reply , Kiran.

Nesting didn't work too.

So, here's what I did.

1) As mentioned earlier the below mentioned statement gives correct result
If(?pVersion? = 'budget') then ( [abc]=1)
else ([def] =1)


2) Used the year parameter alone which is causing issue
If(?pYear? = '2017') then ( [abc]=1)
else ([def] =1)

This gives me data only for the 'else' filter( [def] =1) and skips [abc]=1 on its own.

Tried working around with cast function thinking it could be something related to the data types but no luck.

Any help is appreciated.
Thanks